note 103842 added to book.sqlite
| From: | nosdudefratgmaildotcom at osu1 dot php dot net | Date: | Fri, 06 May 2011 10:34:07 +0000 |
| Subject: | note 103842 added to book.sqlite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179483@lists.php.net to get a copy of this message | ||
Regarding the table creation you can optimize this code a bit by using the built in " CREATE
TABLE IF NOT EXISTS <tablename>". This will let the table creation decision to the sqlite
engine.
Then, if i may, your code could be something like :
<?php
if ($db = new SQLiteDatabase('filename')) {
// first let the engine check table, and create it eventualy
$q = @$db->query('CREATE TABLE IF NOT EXISTS tablename (id int, requests int,
PRIMARY KEY (id))';
//the rest of the code, according error checks etc
// ...
?>
For more "tweaks" feel free to look at sqlite language ref : http://www.sqlite.org/lang_createtable.html
Have fun with this powerfull&simple engine :)
----
Server IP: 69.147.83.197
Probable Submitter: 88.191.77.228
----
Manual Page -- http://www.php.net/manual/en/book.sqlite.php
Edit -- https://master.php.net/note/edit/103842
Del: integrated -- https://master.php.net/note/delete/103842/integrated
Del: useless -- https://master.php.net/note/delete/103842/useless
Del: bad code -- https://master.php.net/note/delete/103842/bad+code
Del: spam -- https://master.php.net/note/delete/103842/spam
Del: non-english -- https://master.php.net/note/delete/103842/non-english
Del: in docs -- https://master.php.net/note/delete/103842/in+docs
Del: other reasons-- https://master.php.net/note/delete/103842
Reject -- https://master.php.net/note/reject/103842
Search -- https://master.php.net/manage/user-notes.php