我试图用fetch_object创建函数。代码未运行并返回错误 PHP致命错误:在布尔值上调用成员函数fetch_object()
下面是供您查看的代码:
function get_result($res, $mth, $proj) {
$db = new mysqli(DB_SERVER,DB_UID,DB_PWD,DB_USEDB) or die(mysqli_connect_error());
if ($res == 'atput') {
if ($proj == 'fb') {
$stmt = "SELECT sum(atput) as atput FROM dsp WHERE dsp.mth=$mth and dsp.proj not in ('fjb','fgt','lb','ptps')";
}
else {
$stmt = "SELECT dsp.atput FROM dsp WHERE dsp.mth=$mth and dsp.proj='$proj'";
}
$q = $db->query($stmt);
$r = $q->fetch_object();
return $r->atput;
}
}