Hi all,
I wrote this function to check if a table exists in the database or not. It seems to work just wondering if this is the best method or if you have any comments. =D Thanks in advance!
function checkTable($db,$table) {
// check if $db is a valid MySQLi resource
if( !is_object($db) || get_class($db) != 'mysqli' ) {
trigger_error('First argument is not a valid mysqli resource as supplied to checkTable.',E_USER_NOTICE);
return FALSE;
}
$sql = 'SELECT 1 FROM `'.$table.'` LIMIT 0';
if( $db->query($sql) )
return TRUE;
else
return FALSE;
}