note 103841 deleted from book.sqlite by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 May 2011 14:02:08 +0000 |
| Subject: | note 103841 deleted from book.sqlite by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179488@lists.php.net to get a copy of this message | ||
Note Submitter: nosdudefr at gmail dot com
----
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 :)