note 98038 added to pdostatement.fetchcolumn

hello_@tm@rk_burakueda.com
Newsgroups php.notes
Message-ID <[email protected]>
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();
?>
----
Server IP: 219.94.145.73
Probable Submitter: 122.103.250.187
----
Manual Page -- http://www.php.net/manual/en/pdostatement.fetchcolumn.php
Edit        -- https://master.php.net/note/edit/98038
Del: integrated  -- https://master.php.net/note/delete/98038/integrated
Del: useless     -- https://master.php.net/note/delete/98038/useless
Del: bad code    -- https://master.php.net/note/delete/98038/bad+code
Del: spam        -- https://master.php.net/note/delete/98038/spam
Del: non-english -- https://master.php.net/note/delete/98038/non-english
Del: in docs     -- https://master.php.net/note/delete/98038/in+docs
Del: other reasons-- https://master.php.net/note/delete/98038
Reject      -- https://master.php.net/note/reject/98038
Search      -- https://master.php.net/manage/user-notes.php
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.