note 94980 modified in ref.sqlite by danbrown
| From: | danbrown@php.net | Date: | Sun, 06 Dec 2009 19:04:45 +0000 |
| Subject: | note 94980 modified in ref.sqlite by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163623@lists.php.net to get a copy of this message | ||
a simplier way to find out if a table exists:
<?php
$db=sqlite_open('mydb.sqlite', 0666, $sqliteerror);
$query = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table' and
name='the_table_Im_looking_for'");
$totaltables = sqlite_num_rows($query);
if ($totaltables<1){
/* table does not exist...create it or do something... */
}
else{
/* table exists...don't create again , do something else */
}
?>
--was--
a simplier way to find out if a table exists:
$db=sqlite_open(mydb.sqlite', 0666, $sqliteerror);
$query = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table' and
name='the_table_Im_looking_for'");
$totaltables = sqlite_num_rows($query);
if ($totaltables<1){
/* table does not exist...create it or do something... */
}
else{
/* table exists...don't create again , do something else */
}
http://php.net/manual/en/ref.sqlite.php