note 46747 added to ref.sqlite

From: Date: Fri, 22 Oct 2004 01:26:29 +0000
Subject: note 46747 added to ref.sqlite
Groups: php.notes 
Request: Send a blank email to php-notes+get-78917@lists.php.net to get a copy of this message
If you need to check if a table exists, you can use a function like this: <?php //Returns TRUE if table exists and FALSE otherwise // $mytable = table you want to check for function sqlite_table_exists($mytable) { $db = sqlite_open('mydb.sqlite', 0666, $sqliteerror); $query = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table'"); $tables = sqlite_fetch_array($query); if ($tables != '') { foreach ($tables as $table) { if ($table == $mytable) { return("TRUE"); } else { return("FALSE"); } } } else { return("FALSE"); } } ?> A function like this could be used to create the table if it's not already created, etc. ---- Manual Page -- http://www.php.net/manual/en/ref.sqlite.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46747 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46747&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46747&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78917) next »