嗨我知道这可能非常简单,经过几个小时的谷歌搜索我已经空手而归,我正在尝试将LIST TABLES查询存储到一个数组中,我可以检查另一个数组中的值是否在生成的LIST表中查询。
$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) {
//}
}
感谢Andy ,非常感谢帮助
答案 0 :(得分:0)
您需要在循环中调用fetch_row()
以获取结果的所有行。
$result = $SQL->doQuery("SHOW TABLES IN sellmygadgets");
while ($row = $result->fetch_row()) {
$table = $row[0];
if (in_array($table, $tables)) {
...
}
}
答案 1 :(得分:0)
$result = $SQL->doQuery("SHOW TABLES IN sellmygadgets");
while ($row = $result->fetch_row()) {
$rows[$i] = $row[0];
$i++;
}
print_r ($rows);
foreach ($tables as $table){
echo "<br> Table " . $table . " Contains this many rows : " . $SQL->numRows(select_all($table)) . "<br>";
if (in_array($table, $rows, TRUE)) {
echo $table . " deos exist <br>";
} else {
echo $table . " does not exist <br>";
}
}