public function fetch_all_by_fids($fids, $start = 0, $limit = 20)
 {
     if (empty($fids)) {
         return array();
     }
     return DB::fetch_all("SELECT * FROM %t WHERE %i ORDER BY dateline DESC %i", array($this->_table, DB::field('fid', $fids), DB::limit($start, $limit)), 'tid');
 }
 public function fetch_all_by_uid($uid, $new, $type, $start, $perpage)
 {
     $new = intval($new);
     $type = $type ? ' AND ' . DB::field('type', $type) : '';
     $new = ' AND ' . DB::field('new', $new);
     return DB::fetch_all("SELECT * FROM %t WHERE uid=%d %i %i ORDER BY new DESC, dateline DESC %i", array($this->_table, $uid, $type, $new, DB::limit($start, $perpage)));
 }
Example #3
0
 function fetch_all($start, $limit, $where = '', $field = 'dateline', $sort = 'DESC')
 {
     if ($where) {
         $wherestr = "WHERE " . $where;
     }
     return DB::fetch_all("SELECT * FROM %t {$wherestr} ORDER BY %i {$sort} " . DB::limit($start, $limit), array($this->_table, $field));
 }
Example #4
0
 public function fetch_all_by_search($username, $start = 0, $limit = 0, $order = 'dateline', $sort = 'DESC')
 {
     $ordersql = $order ? " ORDER BY {$order} {$sort} " : '';
     $wheresql = 'WHERE 1';
     $wheresql .= $username ? ' AND ' . DB::field('username', $username, 'like') : '';
     return DB::fetch_all('SELECT * FROM %t %i %i ' . DB::limit($start, $limit), array($this->_table, $wheresql, $ordersql));
 }
 public function fetch_all_by_bid($bid, $isverified = 1, $start = 0, $limit = 0, $bannedids = array(), $format = true)
 {
     $data = array();
     if ($bid = dintval($bid, true)) {
         $addsql = $bannedids = dintval($bannedids, true) ? ' AND id NOT IN (' . dimplode($bannedids) . ')' : '';
         $query = DB::query('SELECT * FROM %t WHERE ' . DB::field('bid', $bid) . ' AND isverified=%d' . $addsql . ' ORDER BY stickgrade DESC, displayorder DESC, verifiedtime DESC, dataid DESC ' . DB::limit($start, $limit), array($this->_table, $isverified));
         while ($value = DB::fetch($query)) {
             if ($format) {
                 $value['fields'] = unserialize($value['fields']);
                 $value['fields']['timestamp'] = $value['fields']['dateline'];
                 $value['fields']['dateline'] = dgmdate($value['fields']['dateline']);
                 $value['pic'] = $value['pic'] !== STATICURL . 'image/common/nophoto.gif' ? $value['pic'] : '';
                 if ($value['pic'] && $value['picflag'] == '1') {
                     $value['pic'] = getglobal('setting/attachurl') . $value['pic'];
                 } elseif ($value['picflag'] == '2') {
                     $value['pic'] = getglobal('setting/ftp/attachurl') . $value['pic'];
                 }
                 $value['dateline'] = dgmdate($value['dateline'], 'u');
                 $value['verifiedtime'] = dgmdate($value['verifiedtime'], 'u');
             }
             $data[$value['id']] = $value;
         }
     }
     return $data;
 }
Example #6
0
 /**
  *
  * @param string $order
  * @param int $limit Default is 10
  * @return object|null
  */
 public function getTags($order, $limit = 10)
 {
     if (!Config::get('home' . ucfirst($order), 'tags')) {
         return NULL;
     }
     if ($order == 'latest') {
         DB::select('tag');
         DB::from('tag');
         DB::orderBy('id', 'desc');
     } else {
         if ($order == 'random') {
             $range = $this->_tagsRandomRange();
             DB::select('tag');
             DB::from('tag');
             DB::whereGreaterEqual('id', $range['start']);
             DB::whereLessEqual('id', $range['end']);
             DB::orderBy('id', 'rand');
         }
     }
     $configLimit = Config::get('home' . ucfirst($order) . 'Limit', 'tags');
     if ($configLimit) {
         $limit = $configLimit;
     }
     DB::limit($limit);
     DB::run();
     return DB::getResults();
 }
 public function fetch_all_by_uid($uid, $type = 0, $start = 0, $limit = 20)
 {
     if (!$uid) {
         return false;
     }
     return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND type=%d ORDER BY dateline DESC ' . DB::limit($start, $limit), array($this->_table, $uid, $type), 'tid');
 }
Example #8
0
File: model.php Project: web3d/tch
 /**
  * 获取全部数据,适用于少量数据
  * @param string|array $condition 条件
  * @param string $field 字段
  * @param string $pageIndex 页码
  * @param string $pageSize 每页数量
  * @param string $orderBy 排序
  * @param string $keyField 用作键名的字符串
  * @return array
  */
 public function fetchAll($condition = '1=1', $field = '*', $pageIndex = 1, $pageSize = 500, $orderBy = '', $keyField = '')
 {
     $limit = DB::limit((max($pageIndex, 1) - 1) * $pageSize, $pageSize);
     $sql = "SELECT {$field} FROM %t WHERE " . $this->buildWhereStr($condition) . " {$orderBy} {$limit}";
     $data = DB::fetch_all($sql, array($this->_table), $keyField);
     return $data;
 }
 public function fetch_all_by_uids($uids, $start = 0, $limit = 0)
 {
     $result = array();
     if ($uids) {
         $result = DB::fetch_all('SELECT * FROM ' . DB::table($this->_table) . ' WHERE ' . DB::field('uid', $uids) . ' ORDER BY dateline DESC ' . DB::limit($start, $limit));
     }
     return $result;
 }
 public function fetch_all_for_thread($tid, $start = 0, $limit = 100, $uid = 0, $master = 0)
 {
     $verifiedsql = empty($master) ? ' AND verified=1' : '';
     if (intval($uid)) {
         $verifiedsql .= ' AND uid=' . intval($uid);
     }
     return DB::fetch_all("SELECT * FROM %t WHERE tid=%d {$verifiedsql} ORDER BY dateline DESC" . DB::limit($start, $limit), array($this->_table, $tid));
 }
 public function fetch_all_by_cid($cid, $action, $limit)
 {
     if (!$cid) {
         return DB::fetch_all('SELECT * FROM %t ' . ($action ? 'WHERE ' . DB::field('action', $action) : '') . ' ORDER BY cid DESC ' . DB::limit($limit), array($this->_table), $this->_pk);
     } else {
         return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('cid', $cid, '<') . ($action ? ' AND ' . DB::field('action', $action) : '') . ' ORDER BY cid DESC ' . DB::limit($limit), array($this->_table), $this->_pk);
     }
 }
Example #12
0
 public function fetch_all_by_uid($uid, $start = 0, $limit = 0)
 {
     $data = array();
     $query = DB::query('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC ' . DB::limit($start, $limit), array($this->_table, $uid));
     while ($value = DB::fetch($query)) {
         $data[$value['buid']] = $value;
     }
     return $data;
 }
Example #13
0
 public function fetch_all_by_daytime($daytime, $start = 0, $limit = 0, $sort = 'ASC')
 {
     $wheresql = '';
     $parameter = array($this->_table);
     if ($daytime) {
         $wheresql = 'WHERE daytime>=%d';
         $parameter[] = $daytime;
     }
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY daytime {$sort}" . DB::limit($start, $limit), $parameter);
 }
Example #14
0
 public function range($start = 0, $limit = 0)
 {
     $data = array();
     $query = DB::query('SELECT * FROM ' . DB::table($this->_table) . ' ORDER BY displayorder,catid' . DB::limit($start, $limit));
     while ($value = DB::fetch($query)) {
         $value['catname'] = dhtmlspecialchars($value['catname']);
         $data[$value['catid']] = $value;
     }
     return $data;
 }
 public function fetch_all_by_id_idtype($id, $idtype, $start = 0, $limit = 0)
 {
     $id = dintval($id, is_array($id) ? true : false);
     $parameter = array($this->_table, $id, $idtype);
     $wherearr = array();
     $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
     $wherearr[] = 'idtype=%s';
     $wheresql = ' WHERE ' . implode(' AND ', $wherearr);
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY dateline DESC " . DB::limit($start, $limit), $parameter);
 }
 public function fetch_all_by_ctid($ctid, $start = 0, $limit = 0, $distinct = 0)
 {
     if (!$ctid) {
         return null;
     }
     if ($distinct == 1) {
         $sql = " GROUP BY tid";
     }
     return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('ctid', $ctid) . $sql . ' ORDER BY dateline DESC ' . DB::limit($start, $limit), array($this->_table), 'tid');
 }
 public function fetch_all_by_search($uid = 0, $fuid = 0, $fusername = '', $buydatestart = 0, $buydateend = 0, $inviteip = '', $code = '', $start = 0, $limit = 0)
 {
     $condition = $this->make_query_condition($uid, $fuid, $fusername, $buydatestart, $buydateend, $inviteip, $code);
     $data = array();
     $query = DB::query("SELECT * FROM %t {$condition['0']} " . DB::limit($start, $limit), $condition[1]);
     while ($value = DB::fetch($query)) {
         $this->_uids[$value['uid']] = $value['uid'];
         $data[] = $value;
     }
     return $data;
 }
Example #18
0
 public function fetch_all_by_uid($uid, $limit = 0, $orderby = 'dateline', $order = 'DESC', $start = 0)
 {
     //返回用户最新的视频,按时间倒序排列
     $ordersql = $orderby ? ' ORDER BY ' . $orderby . ' ' . $order : '';
     $limitsql = $limit ? DB::limit($start, $limit) : '';
     $data = array();
     foreach (DB::fetch_all("SELECT * FROM %t  WHERE uid= %d {$ordersql} {$limitsql}", array($this->_table, $uid)) as $value) {
         $data[$value['vid']] = $value;
     }
     return $data;
 }
Example #19
0
 public function fetch_all_by_uid($uid, $limit = 0, $orderby = 'dateline', $order = 'DESC', $start = 0)
 {
     //返回用户最新的图片,按时间倒序排列
     $ordersql = $orderby ? ' ORDER BY ' . $orderby . ' ' . $order : '';
     $limitsql = $limit ? DB::limit($start, $limit) : '';
     $image = array();
     foreach (DB::fetch_all("SELECT picid FROM %t  WHERE uid= %d {$ordersql} {$limitsql}", array($this->_table, $uid)) as $value) {
         $image[$value['picid']] = self::fetch_by_picid($value['picid']);
     }
     return $image;
 }
 public function fetch_all_by_uid_username($uid, $username = '', $start = 0, $limit = 0)
 {
     $parameter = array($this->_table, $uid);
     $wherearr = array('uid=%d');
     if (!empty($username)) {
         $parameter[] = $username . '%';
         $wherearr[] = "fusername LIKE %s";
     }
     $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY dateline DESC " . DB::limit($start, $limit), $parameter);
 }
 public function fetch_all_by_uid($uids, $flag = true, $sort = 'ASC', $start = 0, $limit = 0)
 {
     $wherearr = array();
     $sort = $sort === 'ASC' ? 'ASC' : 'DESC';
     if ($uids = dintval($uids)) {
         $wherearr[] = DB::field('uid', $uids);
     }
     if (!$flag) {
         $wherearr[] = 'inheritedtplname = \'\'';
     }
     $where = $wherearr ? ' WHERE ' . implode(' AND ', $wherearr) : '';
     return DB::fetch_all('SELECT * FROM ' . DB::table($this->_table) . $where . ' ORDER BY uid ' . $sort . ', inheritedtplname' . DB::limit($start, $limit), NULL, $uids && !is_array($uids) ? 'bid' : '');
 }
function digest($uid, $digest, $start = 0, $limit = 0, $tableid = 0, $digestglue = '>=', $displayorder = 0, $glue = '>=')
{
    $thread_obj = C::t('forum_thread');
    $parameter = array($thread_obj->get_table_name($tableid), $digest, $displayorder);
    $digestglue = helper_util::check_glue($digestglue);
    $glue = helper_util::check_glue($glue);
    if ($uid) {
        $where = 'authorid=' . $uid . ' AND ';
    }
    $data = DB::fetch_all("SELECT * FROM %t WHERE " . $where . " digest{$digestglue}%d AND displayorder{$glue}%d" . DB::limit($start, $limit), $parameter, 'tid');
    $data[count] = DB::result_first("SELECT count(*) FROM %t WHERE " . $where . " digest{$digestglue}%d AND displayorder{$glue}%d", $parameter, 'tid');
    return $data;
}
 public function fetch_all($ctid, $order = false, $start = 0, $limit = 0)
 {
     if (!$ctid) {
         return null;
     }
     $sql = DB::field('ctid', $ctid);
     if ($order) {
         $sql .= ' ORDER BY ' . DB::order('dateline', 'DESC');
     }
     if ($limit) {
         $sql .= DB::limit($start, $limit);
     }
     return DB::fetch_all('SELECT * FROM %t WHERE ' . $sql, array($this->_table));
 }
Example #24
0
 public function fetch_all_by_lastactivity_invisible($timestamp, $invisible = 0, $start = 0, $limit = 0)
 {
     $data = array();
     if ($timestamp) {
         $addsql = '';
         if ($invisible === 1) {
             $addsql = ' AND invisible = 1';
         } elseif ($invisible === 2) {
             $addsql = ' AND invisible = 0';
         }
         $data = DB::fetch_all('SELECT * FROM %t WHERE lastactivity >= %d' . $addsql . ' ORDER BY lastactivity DESC' . DB::limit($start, $limit), array($this->_table, $timestamp), $this->_pk);
     }
     return $data;
 }
 public function fetch_all_by_type_find($type = null, $find = null, $start = 0, $limit = 0)
 {
     $parameter = array($this->_table);
     $wherearr = array();
     if ($type !== null) {
         $parameter[] = $type;
         $wherearr[] = "`type`=%d";
     }
     if ($find !== null) {
         $parameter[] = '%' . addslashes(stripsearchkey($find)) . '%';
         $wherearr[] = "`find` LIKE %s";
     }
     $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY find ASC" . DB::limit($start, $limit), $parameter);
 }
Example #26
0
 public function fetch_all_by_search($uid = null, $status = null, $orderid = null, $email = null, $username = null, $buyer = null, $admin = null, $submit_starttime = null, $submit_endtime = null, $confirm_starttime = null, $confirm_endtime = null, $start = null, $limit = null)
 {
     $sql = '';
     $sql .= $uid !== null ? ' AND o.' . DB::field('uid', dintval($uid)) : '';
     $sql .= $status ? ' AND o.' . DB::field('status', $status) : '';
     $sql .= $orderid ? ' AND o.' . DB::field('orderid', $orderid) : '';
     $sql .= $email ? ' AND o.' . DB::field('email', $email) : '';
     $sql .= $username ? ' AND m.' . DB::field('username', $username) : '';
     $sql .= $buyer ? ' AND o.' . DB::field('buyer', $buyer) : '';
     $sql .= $admin ? ' AND o.' . DB::field('admin', $admin) : '';
     $sql .= $submit_starttime ? ' AND o.' . DB::field('submitdate', $submit_starttime, '>=') : '';
     $sql .= $submit_endtime ? ' AND o.' . DB::field('submitdate', $submit_endtime, '<') : '';
     $sql .= $confirm_starttime ? ' AND o.' . DB::field('confirmdate', $confirm_starttime, '>=') : '';
     $sql .= $confirm_endtime ? ' AND o.' . DB::field('confirmdate', $confirm_endtime, '<') : '';
     return DB::fetch_all('SELECT o.*' . ($uid !== 0 ? ', m.username' : '') . ' FROM %t o' . ($uid !== 0 ? ', ' . DB::table('common_member') . ' m WHERE o.uid=m.uid' : ' WHERE 1 ') . ' %i ORDER BY o.submitdate DESC ' . DB::limit($start, $limit), array($this->_table, $sql));
 }
Example #27
0
 public function fetch_all_by_uid_icon($uids = null, $icon = '', $start = 0, $limit = 0)
 {
     $parameter = array($this->_table);
     $wherearr = array();
     if ($uids !== null) {
         $uids = dintval($uids, true);
         $wherearr[] = is_array($uids) ? 'uid IN(%n)' : 'uid=%d';
         $parameter[] = $uids;
     }
     if (!empty($icon)) {
         $wherearr[] = 'icon=%s';
         $parameter[] = $icon;
     }
     $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY dateline DESC " . DB::limit($start, $limit), $parameter, $this->_pk);
 }
Example #28
0
 public function fetch_all_by_status($status = NUll, $tagname = '', $startlimit = 0, $count = 0, $returncount = 0, $order = '')
 {
     if ($status === NULL) {
         $statussql = 'status<>3';
     } else {
         $statussql = 'status=' . intval($status);
     }
     $data = array($this->_table);
     if ($tagname) {
         $namesql = " AND tagname LIKE %s";
         $data[] = '%' . $tagname . '%';
     }
     if ($returncount) {
         return DB::result_first("SELECT count(*) FROM %t WHERE {$statussql} {$namesql}", $data);
     }
     return DB::fetch_all("SELECT * FROM %t WHERE {$statussql} {$namesql} ORDER BY " . DB::order('tagid', $order) . " " . DB::limit($startlimit, $count), $data);
 }
 public function fetch_all_for_search($cid, $ctid, $username, $uid, $useip, $rate, $message, $starttime, $endtime, $start = 0, $limit = 20)
 {
     $where = '1';
     $where .= $cid ? ' AND ' . DB::field('cid', $cid) : '';
     $where .= $ctid ? ' AND ' . DB::field('ctid', $ctid) : '';
     $where .= $username ? ' AND ' . DB::field('username', '%' . stripsearchkey($username) . '%', 'like') : '';
     $where .= $uid ? ' AND ' . DB::field('uid', $uid) : '';
     $where .= $useip ? ' AND ' . DB::field('useip', stripsearchkey($useip) . '%', 'like') : '';
     $where .= $rate ? ' AND ' . DB::field('rate', $rate, '>') : '';
     $where .= $message ? ' AND ' . DB::field('message', '%' . stripsearchkey($message) . '%', 'like') : '';
     $where .= $starttime != '' ? ' AND ' . DB::field('dateline', $starttime, '>') : '';
     $where .= $endtime != '' ? ' AND ' . DB::field('dateline', $endtime, '<') : '';
     if ($start == -1) {
         return DB::result_first("SELECT count(*) FROM %t WHERE %i", array($this->_table, $where));
     }
     return DB::fetch_all("SELECT * FROM %t WHERE %i ORDER BY dateline DESC %i", array($this->_table, $where, DB::limit($start, $limit)));
 }
Example #30
0
 public function fetch_all_by_uid_idtype($uid, $idtype, $favid = 0, $start = 0, $limit = 0)
 {
     $parameter = array($this->_table);
     $wherearr = array();
     if ($favid) {
         $parameter[] = dintval($favid, is_array($favid) ? true : false);
         $wherearr[] = is_array($favid) ? 'favid IN(%n)' : 'favid=%d';
     }
     $parameter[] = $uid;
     $wherearr[] = "uid=%d";
     if (!empty($idtype)) {
         $parameter[] = $idtype;
         $wherearr[] = "idtype=%s";
     }
     $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
     return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY dateline DESC " . DB::limit($start, $limit), $parameter, $this->_pk);
 }