note 103841 added to book.sqlite

From: Date: Fri, 06 May 2011 10:25:36 +0000
Subject: note 103841 added to book.sqlite
Groups: php.notes 
Request: Send a blank email to php-notes+get-179482@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/103841 Del: integrated -- https://master.php.net/note/delete/103841/integrated Del: useless -- https://master.php.net/note/delete/103841/useless Del: bad code -- https://master.php.net/note/delete/103841/bad+code Del: spam -- https://master.php.net/note/delete/103841/spam Del: non-english -- https://master.php.net/note/delete/103841/non-english Del: in docs -- https://master.php.net/note/delete/103841/in+docs Del: other reasons-- https://master.php.net/note/delete/103841 Reject -- https://master.php.net/note/reject/103841 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179482) next »