note 31861 added to function.mysql-list-tables
| From: | thebitman at attbi dot com | Date: | Wed, 07 May 2003 06:49:37 +0000 |
| Subject: | note 31861 added to function.mysql-list-tables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47610@lists.php.net to get a copy of this message | ||
okay everybody, the fastest, most accurate, safest method:
function mysql_table_exists($table, $link)
{
$exists = mysql_query("SELECT 1 FROM
$table LIMIT 0", $link);
if ($exists) return true;
return false;
}
Note the "LIMIT 0", I mean come on, people, can't get much faster than that! :)
As far as a query goes, this does absolutely nothing. But it has the ability to fail if the table
doesnt exist, and that's all you need!
--
http://www.php.net/manual/en/function.mysql-list-tables.php
http://master.php.net/manage/user-notes.php?action=edit+31861
http://master.php.net/manage/user-notes.php?action=delete+31861
http://master.php.net/manage/user-notes.php?action=reject+31861