
Untitled
By: a guest on
May 1st, 2012 | syntax:
None | size: 0.53 KB | hits: 10 | expires: Never
Determine table existence
SELECT * FROM table WHERE FALSE;
SELECT * FROM table WHERE 0;
SELECT * FROM table WHERE column = false;
if there's table `table`
return 0 rows (minimal database overhead) and valid resource
else
return false
SELECT count(*)
FROM information_schema.tables
WHERE table_schema = <schema-or-db-name>
AND table_name = <table-or-view-name>
$sql="SELECT * FROM $table";
$result=mysql_query($sql);
if (!$result)
{
// table does not exist
}
$sql="SELECT * FROM $table where user_id = 1";