I want to check if a table with a specific name exists in a database I\'ve connected to using PHP and PDO.
It has to work on all database backends, like MySQL, SQLi
Here's what worked for me. It was a combination of several answers:
$table_name = 'your_table_here'; $test = "SELECT 1 FROM " . $table_name . " LIMIT 1"; $test = $db->query($test); //$db needs to be PDO instance if($test) { return 1; //Table exists } else { return 0; //No table in database }