2017-06-06 160 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

相關問題