rendered paste body /** * Count the users in room * * @param string roomId * @return int the count of users * * @global Db */ public function countUsersInRoom($roomId) { global $Db; $Db->execute( 'SELECT COUNT(*) AS count ' . 'FROM chatdata, usersinrooms ' . 'WHERE chatdata.ischatting=1 AND chatdata.uid!=0 AND usersinrooms.room=%s ' . 'AND usersinrooms.id=chatdata.uid AND usersinrooms.id!=0', $roomId ); $tmpCount = $Db->fields[0]['count']; $Db->execute('SELECT id FROM chatrooms WHERE p_id=%u', $roomId); $fields = $Db->fields; for ($i = 0, $max = $Db->recordCount(); $i < $max; $i++) { $Db->execute( 'SELECT COUNT(*) AS count ' . 'FROM chatdata, usersinrooms ' . 'WHERE chatdata.ischatting=1 AND usersinrooms.room=%s AND usersinrooms.id=chatdata.uid AND uid!=0', $fields[$i]['id'] ); $tmpCount += $Db->fields[0]['count']; } return $tmpCount; }