note 74733 added to function.PDO-query
| From: | Ravo at osu1 dot php dot net | Date: | Wed, 25 Apr 2007 14:49:29 +0000 |
| Subject: | note 74733 added to function.PDO-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125859@lists.php.net to get a copy of this message | ||
I struggled with this trying to figure out why I couldn't return a single row using a simple
query. This may or may be obvious but you have to use PDOstatement functions of the result of a
PDO->query(). This took me a while to figure out since it is a far cry from the query functions
of old.
<?php
$connection = new pdo("sqlite:file.sq3");
$query="SELECT * FROM table";
$result = $connection->query($query);
$row = $result->fetch(PDO::FETCH_ASSOC);
print_r($row);
?>
----
Server IP: 64.71.164.2
Probable Submitter: 205.208.133.229
----
Manual Page -- http://www.php.net/manual/en/function.PDO-query.php
Edit -- https://master.php.net/note/edit/74733
Del: integrated -- https://master.php.net/note/delete/74733/integrated
Del: useless -- https://master.php.net/note/delete/74733/useless
Del: bad code -- https://master.php.net/note/delete/74733/bad+code
Del: spam -- https://master.php.net/note/delete/74733/spam
Del: non-english -- https://master.php.net/note/delete/74733/non-english
Del: in docs -- https://master.php.net/note/delete/74733/in+docs
Del: other reasons-- https://master.php.net/note/delete/74733
Reject -- https://master.php.net/note/reject/74733
Search -- https://master.php.net/manage/user-notes.php