2017-06-06 111 views
0

事情是这样的:如何检查数据库表是否存在于PDO中?

$connection->executeQuery('check table historial1 in database $connection->executeQuery('show tables')') 
+0

检查:https://stackoverflow.com/questions/1717495/check-if-a-database-table-exists-using-php-pdo – ruhul

+1

可能的复制[检查数据库表是否存在使用PHP/PDO](https://stackoverflow.com/questions/1717495/check-if-a-database-table-exists-using-php-pdo) – ruhul

回答

0
$sql = "SHOW TABLES 'Table_Name' "; 
    if($this->is_connected) 
    { 
     $query = $this->pdo->query($sql); 
     return $query->fetchAll(PDO::FETCH_COLUMN); 
    } 
    return FALSE; 
+0

尽管此代码可能会回答这个问题提供了关于如何和/或为何解决问题的附加背景,可以提高答案的长期价值。 – Badacadabra

相关问题