note 46973 added to ref.sqlite
| From: | alexsatalphacomolexdotinfo at osu1 dot php dot net | Date: | Thu, 28 Oct 2004 22:41:39 +0000 |
| Subject: | note 46973 added to ref.sqlite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79297@lists.php.net to get a copy of this message | ||
the OO version.
<?php
function sqlite_table_exists($db,$mytable) {
// ask the database kindly what tables is has.
$result = $db->query("SELECT name FROM sqlite_master WHERE type='table'");
$tables = $result->fetchAll();
// if there's no items in the array then our taget is not going to exists.
if (count($tables) == 0) {
return FALSE ;
}
// loop over the tables to see if there's a table we're looking for.
foreach ($tables as $table) {
if ($table['name'] == $mytable) {
return(TRUE);
}
}
// there was no such table, informe the user the bad news.
return(FALSE);
}
?>
----
Manual Page -- http://www.php.net/manual/en/ref.sqlite.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46973
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46973&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46973&report=yes
Search -- http://master.php.net/manage/user-notes.php