可能重复:
MySQL 检查表是否存在而不抛出异常
基本上我有我的 MySQL dbname = test 和我的表名 = page。
我想使用 php PDO 创建一个查询来检查我的数据库“test”中是否存在表“page”
我试过这个,但它确实有效..它总是告诉我它不存在..即使它确实存在
if (array_search('pages',$db->query('show tables')->fetch()) !== false) { echo "the db exists";
} else { echo "the db doesnt exists";
// Create tableS
//$IDB->execute();
}