我想执行一个函数,但我上面有这些问题 代码是
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);
}
答案 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;