note 98038 deleted from pdostatement.fetchcolumn by danbrown
| From: | danbrown@php.net | Date: | Sat, 22 May 2010 04:08:39 +0000 |
| Subject: | note 98038 deleted from pdostatement.fetchcolumn by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169511@lists.php.net to get a copy of this message | ||
Note Submitter: hello_ at tm at rk_burakueda dot com
----
Not only you cannot receive another column from the same row, but also it seems you cannot call
fetchColumn() more than once:
<?php
$result = $dbconn->query("SELECT product_quantity FROM products WHERE product_id =
'1234'");
//this will yield correct result:
echo $result->fetchColumn();
//but this won't
if($result->fetchColumn() > 0){
echo $result->fetchColumn();
}
?>
so you have to assign it to a variable if you want to use it multiple times:
<?php
$quantity = $result->fetchColumn();
?>