note 103842 deleted from book.sqlite by cmb
| From: | cmb@php.net | Date: | Fri, 02 Sep 2016 14:09:28 +0000 |
| Subject: | note 103842 deleted from book.sqlite by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206468@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 :)