获取错误 - 致命错误:在布尔值上调用成员函数fetch_array()

时间:2016-05-16 15:39:30

标签: php mysqli

当我执行以下代码时,我得到标题中描述的错误代码:

function getBrands($b_showAll) {
    global $mysql;

    if($b_showAll==true) {
        $query = $mysql->query("SELECT * FROM producer");
    }

    else {
        $query = $mysql->query("SELECT * FROM producer WHERE (active = 1)");
    }

    $result = array();
    while($row = $query->fetch_array()) {
        $brand = new brand();
        $brand->name = $row['name'];
        $brand->logo = $row['logo'];
        $brand->active = $row['active'];
        array_push($result, $brand);
    }   
    return $result;
}

如何解决这个问题?

0 个答案:

没有答案