语法错误调用未定义的方法mysqli :: num_rows()

时间:2014-11-07 09:46:18

标签: php mysqli

我想执行一个函数,但我上面有这些问题 代码是

public function update_stats(){
    $mysqli = $this->connection();
    $activo ='1';
    $q1 = $mysqli->fetch_row($mysqli->query("SELECT COUNT(id) FROM usuarios WHERE activo = '$activo'"));
    $q2 = $mysqli->num_rows($mysqli->query('SELECT COUNT(id) FROM images'));
      $return['stats_miembros'] = $q1[0];
        $return['stats_images'] = $q2;
        $is_online = (time() - ($tsCore->settings['c_last_active'] * 60));
        $cueri = $mysqli->num_rows($mysqli->query('SELECT COUNT(id) FROM `usuarios` WHERE `last_active` > \''.$is_online.'\''));
        $return['stats_online'] = $cueri;
        return $return;
}

我在这里得到了语法错误:

$q1 = $mysqli->fetch_row($mysqli->query("SELECT COUNT(id) FROM usuarios WHERE activo = '$activo'"));

$mysqli = $this->connection();功能是:

private function connection(){
        return new mysqli($this->serv,$this->user,$this->pass,$this->base);
    }

1 个答案:

答案 0 :(得分:0)

试试这个 -

$q2 = $mysqli->query('SELECT COUNT(id) FROM images');
$numRows = $q2->num_rows;

$cueri = $mysqli->query('SELECT COUNT(id) FROM `usuarios` WHERE `last_active` > \''.$is_online.'\'');
$numRowsNew = $cueri->num_rows;

$mysqli_result->num_rows;