note 110601 deleted from class.sqlite3result by aharvey
| From: | aharvey@php.net | Date: | Mon, 12 Nov 2012 05:01:59 +0000 |
| Subject: | note 110601 deleted from class.sqlite3result by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191888@lists.php.net to get a copy of this message | ||
Note Submitter: ironiridis at gmail dot com
----
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.