嗨,我知道这可能非常简单,经过几个小时的谷歌搜索后,我空手返回,我正在尝试将列表表查询存储到一个数组中,在其中我可以检查另一个数组中的值是否在结果列表表中查询。
$SQL = new DB;
$tables = array(
"Product_Cache",
"Product_Cat",
"Product_Details",
"Product_Images",
"Site_Content",
"UserDetails",
"User_Products",
"User_Type",
"Users"
);
$result = $SQL->doQuery("SHOW TABLES IN sellmygadgets");
$row = $result->fetch_assoc();
foreach ($tables as $table){
echo "Table " . $table . " Contains this many rows : " . $SQL->numRows(select_all($table)) . "<br>";
//if(in_array($table, $row, TRUE) {
//}
}
非常感谢安迪的帮助
最佳答案
您需要在循环中调用fetch_row()
来获取结果的所有行。
$result = $SQL->doQuery("SHOW TABLES IN sellmygadgets");
while ($row = $result->fetch_row()) {
$table = $row[0];
if (in_array($table, $tables)) {
...
}
}
关于php - 列出 in_array 中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20203285/