note 118707 added to sqlite3.prepare
| From: | VenkataSubbaraju | Date: | Fri, 22 Jan 2016 12:27:18 +0000 |
| Subject: | note 118707 added to sqlite3.prepare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204747@lists.php.net to get a copy of this message | ||
Without checking the return value of "prepare" if "exec" is used then it will
cause Fatal Error.
"PHP Fatal error: Call to a member function execute() on a non-object "
To avoid this error,need to check return value as following:
<?php
$db = new SQLite3('school.db');
if($stmt = $db->prepare('SELECT id,student_name FROM classTen '))
{
$result = $stmt->execute();
$names=array();
while($arr=$result->fetchArray(SQLITE3_ASSOC))
{
$names[$arr['id']]=$arr['student_name'];
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 103.19.212.21 (proxied: 103.19.212.253)
----
Manual Page -- http://php.net/manual/en/sqlite3.prepare.php
Edit -- https://master.php.net/note/edit/118707
Del: integrated -- https://master.php.net/note/delete/118707/integrated
Del: useless -- https://master.php.net/note/delete/118707/useless
Del: bad code -- https://master.php.net/note/delete/118707/bad+code
Del: spam -- https://master.php.net/note/delete/118707/spam
Del: non-english -- https://master.php.net/note/delete/118707/non-english
Del: in docs -- https://master.php.net/note/delete/118707/in+docs
Del: other reasons-- https://master.php.net/note/delete/118707
Reject -- https://master.php.net/note/reject/118707
Search -- https://master.php.net/manage/user-notes.php