Re: how to check if a mysql table exists
| From: | Jake Malone | Date: | Wed, 23 Apr 2003 17:48:16 +0000 |
| Subject: | Re: how to check if a mysql table exists | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145054@lists.php.net to get a copy of this message | ||
From the PHP manual comments
(http://www.php.net/manual/en/function.mysql-list-tables.php). There's a few
other user-posted solutions for this as well.
function mysql_table_exists($dbLink, $database, $tableName)
{
$tables = array();
$tablesResult = mysql_list_tables($database, $dbLink);
while ($row = mysql_fetch_row($tablesResult)) $tables[] = $row[0];
return(in_array($tableName, $tables));
}
"Prince" <friendly@kaltelnet.net> wrote in message
news:002301c309bf$efb00680$4904a40c@andy...
> hi..
>
> creating a function that needs to check the existance of a mysql table and
> report error if no table of that name existed .. anybody know how i can do
> this?
>
>
>