note 72609 added to function.pdostatement-fetchcolumn
| From: | seanferd at assmasterdonkeyranch dot com | Date: | Thu, 25 Jan 2007 23:04:13 +0000 |
| Subject: | note 72609 added to function.pdostatement-fetchcolumn | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122208@lists.php.net to get a copy of this message | ||
This is an excellent method for returning a column count. For example:
<?php
$db = new
PDO('mysql:host=localhost;dbname=pictures','user','password');
$pics = $db->query('SELECT COUNT(id) FROM pics');
$this->totalpics = $pics->fetchColumn();
$db = null;
?>
In my case $pics->fetchColumn() returns 641 because that is how many pictures I have in my db.
----
Server IP: 216.194.113.175
Probable Submitter: 72.129.230.242
----
Manual Page -- http://www.php.net/manual/en/function.pdostatement-fetchcolumn.php
Edit -- https://master.php.net/note/edit/72609
Del: integrated -- https://master.php.net/note/delete/72609/integrated
Del: useless -- https://master.php.net/note/delete/72609/useless
Del: bad code -- https://master.php.net/note/delete/72609/bad+code
Del: spam -- https://master.php.net/note/delete/72609/spam
Del: non-english -- https://master.php.net/note/delete/72609/non-english
Del: in docs -- https://master.php.net/note/delete/72609/in+docs
Del: other reasons-- https://master.php.net/note/delete/72609
Reject -- https://master.php.net/note/reject/72609
Search -- https://master.php.net/manage/user-notes.php