php检测mysql表是否存在的方法小结
(编辑:jimmy 日期: 2025/10/29 浏览:3 次 )
本文实例讲述了php检测mysql表是否存在的方法。分享给大家供大家参考,具体如下:
pdo:
<"数据库连接失败".$e->getMessage());
}
$table = 'cy_news';
//判断表是否存在
$result = $pdo->query("SHOW TABLES LIKE '". $table."'");
$row = $result->fetchAll();
if('1' == count($row)){
echo "Table exists";
} else {
echo "Table does not exist";
}
"font-size: medium">mysql:
<"localhost","root","");
mysql_select_db("php_cms", $con);
$table = 'cy_news';
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '". $table."'"))==1) {
echo "Table exists";
} else {
echo "Table does not exist";
}
"_blank" href="https://www.jb51.net/Special/192.htm">PHP基于pdo操作数据库技巧总结》、《php+Oracle数据库程序设计技巧总结》、《PHP+MongoDB数据库操作技巧大全》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
下一篇:Laravel接收前端ajax传来的数据的实例代码