我正在尝试使用 codeigniter 中的 mysql 检查表是否存在,以及该表中是否有可用记录。 这是我试过的功能,但 id 不起作用。
function isRowExist($table, $id)
{
if(mysqli_query("DESCRIBE {$table}")) {
$query = $this->db->query("SELECT * FROM {$table} WHERE id = '{$id}'");
}
return $query->num_rows();
}
如有任何帮助,我们将不胜感激。
最佳答案
您可以试试这个 codeigniter 函数来检查表是否已经存在。
if ($this->db->table_exists('tbl_user')) {
// table exists (Your query)
} else {
// table does not exist (Create table query)
}
关于php - 检查mysql中是否存在表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42383809/