PHP PDO检查mySQL数据库中是否存在具有特定名称的表

问题描述:

以下代码检查数据库中的表.

The following code checks for tables on the database.

function checkdbexists(){
    global $krdb;
    return $krdb->query("show tables");
}

我们要检查是否存在一个名为'systems'的表,如果存在,则返回1,如果没有,则返回null.

We want to check whether a table called 'systems' exists returning 1 if it does and null or 0 if it does not.

您可以使用

array_search('system',$krb->query('show tables')->fetch())!==false;