PDO - Check if table exists

Hi guys,

I need help on a clean way to check if a table exists.

I want to set a variable based on if the table exists or not or if it does and it’s empty set $dbnum to 0

My Current Query is :

$dbnumbers = $db->prepare('SELECT * FROM '.$tablename.'');
$dbnumbers->execute();
$count = $dbnumbers->rowCount();
if ($count == 0) {
$dbnum = "0";
} else {
$dbnum = $count;
}

SHOW TABLES LIKE \‘’ . $tablename . ‘\’

Cheers dude will try this now :slight_smile: