【发布时间】:2012-08-19 06:05:13
【问题描述】:
可能重复:
MySQL check if a table exists without throwing an exception
基本上我有我的 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();
}
【问题讨论】:
-
你做了哪些研究来帮助你找到答案?
-
首先链接不显示 pdo...然后我研究了我没有得到“从 INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name'”示例中选择用户...这就是为什么我希望有人告诉我...