我正在编写 CSV 导入脚本。我遇到了一条通知,上面写着“注意:尝试获取非对象的属性‘num_rows’”。
function getWardByCode($ward, $area_id){
global $db;
$query = $db->query("SELECT `id` FROM `wards` WHERE `code`='{$db->real_escape_string($ward)}', `area_id`='{$db->real_escape_string($area_id)}' LIMIT 1");
if (1 === $query->num_rows){
$data = $query->fetch_assoc();
return $data['id'];
}
$db->query("INSERT INTO `wards` (`code`, `area_id`) VALUES ('{$db->real_escape_string($ward)}', '{$db->real_escape_string($area_id)}')");
return $db->insert_id;
}
宝慕林4294392