note 98038 deleted from pdostatement.fetchcolumn by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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();
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.