Ejemplo n.º 1
0
 private function fetchUsersTotal($filters = array())
 {
     $key = md5(print_r($filters, true));
     if (!($data = $this->getData($this->query_md5 . '_total_' . $key))) {
         foreach ($filters as $filter => $value) {
             $where = (isset($where) ? $where . ' AND ' : ' AND ') . $filter . '="' . $value . '"';
         }
         $rs = DB::select('
             SELECT COUNT(*) as total
             FROM `user` AS `u`
             WHERE CONCAT_WS(" ", u.login, u.email) LIKE(\'' . Tool::getLikeList($this->query) . '\')
             ' . (isset($where) ? $where : '') . '
         ');
         $this->setData($this->query_md5 . '_total_', $data = $rs['data'][0]['total']);
     }
     return $data;
 }
Ejemplo n.º 2
0
 public static function search($page = false, $query = false)
 {
     $from = (!$page ? 0 : $page - 1) * Conf::get('QUESTION_PER_PAGE');
     $max = $page === false ? 0 : Conf::get('QUESTION_PER_PAGE');
     $rs = DB::select('
         SELECT u.id, u.login, u.valided, u.male, u.email, u.zip
         FROM `user` AS `u`
         JOIN `user_result` AS `r` ON r.user_id=u.id
         WHERE valided="1" ' . ($query ? ' AND u.login LIKE(\'' . Tool::getLikeList($query) . '\')' : '') . '
         GROUP BY u.id
         ORDER BY u.register_date DESC
     ', $from, $max);
     $users = array();
     foreach ($rs['data'] as $user) {
         $users[] = new Model_User($user['id'], $user);
     }
     return $users;
 }