note 110601 added to class.sqlite3result
| From: | ironiridis at gmail dot com | Date: | Mon, 12 Nov 2012 04:30:41 +0000 |
| Subject: | note 110601 added to class.sqlite3result | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191887@lists.php.net to get a copy of this message | ||
You may have, as I did, habits to break while migrating away from procedural database stuff (like
pgsql) towards the object-oriented style (such as PDO and SQLite3).
You might also have noticed that $SQLite3->query($sql); returns true, false, or an SQLite3Result.
<?php
$result = @$db->query($_REQUEST['q']);
if (is_resource($result)) {
$rows = array();
while($row = $result->fetchArray(SQLITE3_ASSOC)) $rows[] = $row;
$result->finalize();
result(true, $rows);
} else result($result);
?>
After much silliness and tomfoolery, I realized that is_resource() should actually be is_object(),
since SQLite3 does not return a result resource like the procedural-style database APIs do.
It's returning an object, of course.
----
Server IP: 69.147.83.199
Probable Submitter: 97.116.157.133
----
Manual Page -- http://www.php.net/manual/en/class.sqlite3result.php
Edit -- https://master.php.net/note/edit/110601
Del: integrated -- https://master.php.net/note/delete/110601/integrated
Del: useless -- https://master.php.net/note/delete/110601/useless
Del: bad code -- https://master.php.net/note/delete/110601/bad+code
Del: spam -- https://master.php.net/note/delete/110601/spam
Del: non-english -- https://master.php.net/note/delete/110601/non-english
Del: in docs -- https://master.php.net/note/delete/110601/in+docs
Del: other reasons-- https://master.php.net/note/delete/110601
Reject -- https://master.php.net/note/reject/110601
Search -- https://master.php.net/manage/user-notes.php