note 111658 added to sqlite3.query
| From: | bohwaz | Date: | Wed, 13 Mar 2013 11:47:47 +0000 |
| Subject: | note 111658 added to sqlite3.query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194056@lists.php.net to get a copy of this message | ||
The recommended way to do a SQLite3 query is to use a statement. For a table creation, a query might
be fine (and easier) but for an insert, update or select, you should really use a statement,
it's really easier and safer as SQLite will escape your parameters according to their type.
SQLite will also use less memory than if you created the whole query by yourself. Example:
<?php
$db = new SQLite3;
$statement = $db->prepare('SELECT * FROM table WHERE id = :id;');
$statement->bindValue(':id', $id);
$result = $statement->execute();
?>
You can also re-use a statement and change its parameters, just do $statement->reset(). Finally
don't forget to close a statement when you don't need it anymore as it will free some
memory.
----
Server IP: 113.20.13.217
Probable Submitter: 91.121.179.154
----
Manual Page -- http://php.net/manual/en/sqlite3.query.php
Edit -- https://master.php.net/note/edit/111658
Del: integrated -- https://master.php.net/note/delete/111658/integrated
Del: useless -- https://master.php.net/note/delete/111658/useless
Del: bad code -- https://master.php.net/note/delete/111658/bad+code
Del: spam -- https://master.php.net/note/delete/111658/spam
Del: non-english -- https://master.php.net/note/delete/111658/non-english
Del: in docs -- https://master.php.net/note/delete/111658/in+docs
Del: other reasons-- https://master.php.net/note/delete/111658
Reject -- https://master.php.net/note/reject/111658
Search -- https://master.php.net/manage/user-notes.php