【问题标题】:How to check if a database table exist in PDO?如何检查PDO中是否存在数据库表?
【发布时间】:2017-11-07 00:17:17
【问题描述】:

类似这样的:

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

【问题讨论】:

标签: pdo doctrine-orm native


【解决方案1】:
 $sql = "SHOW TABLES 'Table_Name' ";
    if($this->is_connected)
    {
        $query = $this->pdo->query($sql);
        return $query->fetchAll(PDO::FETCH_COLUMN);
    }
    return FALSE;

【讨论】:

  • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。
猜你喜欢
  • 1970-01-01
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 2011-03-04
  • 2012-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多