public function fetch_all_by_id_idtype($id, $idtype, $start, $limit, $cid = '', $order = '') { if ($cid) { $cidsql = DB::field('cid', $cid) . ' AND '; } return DB::fetch_all('SELECT * FROM %t WHERE ' . $cidsql . ' id=%d AND idtype=%s ORDER BY ' . DB::order('dateline', $order) . ' %i', array($this->_table, $id, $idtype, DB::limit($start, $limit))); }
public function fetch_all($ctid = '', $orderby = '', $ordersc = '', $start = 0, $limit = 0, $title = '', $cachetid = '') { if ($this->_allowmem && $cachetid) { $data = $this->fetch_cache($cachetid, $this->_pre_cache_key . 'tid_'); if ($data) { return $data; } } $sql = ''; if ($ctid) { $sql .= 'WHERE ' . DB::field('ctid', $ctid); } if ($title && str_replace('%', '', $title)) { $sql .= ($sql ? ' AND ' : 'WHERE ') . DB::field('name', '%' . $title . '%', 'like'); } $sql .= ($orderby = DB::order($orderby, $ordersc)) ? ' ORDER BY ' . $orderby : ''; $sql .= ' ' . DB::limit($start, $limit); if (!$sql) { return null; } $data = DB::fetch_all('SELECT * FROM %t %i', array($this->_table, $sql), $this->_pk); if ($this->_allowmem && $cachetid) { $this->store_cache($cachetid, $data, $this->_cache_ttl, $this->_pre_cache_key . 'tid_'); } return $data; }
/** * set data */ public function setData() { $obj = Factory::createObject('News'); $table = DB::table($obj->getTable()); $limit = new base_database_Limit(10); $order = DB::order($table->getColumn('firstEditTime')); $finder = Finder::create('news')->setOrder($order)->setlimit($limit); $this->data = $finder->find(); }
public function fetch_all_by_upid($upid, $order = null, $sort = 'DESC') { $upid = is_array($upid) ? array_map('intval', (array) $upid) : dintval($upid); if ($upid !== null) { $ordersql = $order !== null && !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : ''; return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('upid', $upid) . " {$ordersql}", array($this->_table), $this->_pk); } return array(); }
public function fetch_goods($tid, $pid, $orderby = '', $ascdesc = 'asc', $start = 0, $limit = 0) { if (empty($pid)) { return array(); } if ($tid) { $tidsql = DB::field('tid', $tid) . ' AND '; } if ($orderby) { $ordersql = " ORDER BY " . DB::order($orderby, $ascdesc); } return DB::fetch_first("SELECT * FROM %t WHERE {$tidsql} " . DB::field('pid', $pid) . $ordersql . DB::limit($start, $limit), array($this->_table)); }
public function loadNaviStructure() { $table = DB::table(Factory::createObject('navigationCategory')->getTable()); $order = DB::order($table->getColumn('sort'), base_database_Order::ASC); $columnList = [$table->getColumn('name'), $table->getColumn('LK')]; $cats = Finder::create('navigationCategory')->setOrder($order)->find($columnList); foreach ($cats as $catRow) { $entriesForCategory = $this->loadEntriesForCategory($catRow['LK']); if (!empty($entriesForCategory)) { $this->naviStructure[$catRow['name']] = $entriesForCategory; $this->catLKName[$catRow['name']] = $catRow['LK']; } } }
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)); }
public function fetch_all_by_available_icon($available = null, $haveicon = false, $glue = '=', $order = 'displayorder', $sort = 'ASC') { $parameter = array($this->_table); if ($available !== null) { $parameter[] = $available; $glue = helper_util::check_glue($glue); $wherearr[] = "available{$glue}%d"; } if ($haveicon) { $wherearr[] = "icon!=''"; } $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : ''; $ordersql = !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : ''; return DB::fetch_all("SELECT * FROM %t {$wheresql} {$ordersql}", $parameter, $this->_pk); }
public function fetch_all_by_id($idtype, $ids, $orderby = '') { $attachments = array(); if ($orderby) { $orderby = 'ORDER BY ' . DB::order($orderby, 'DESC'); } if (in_array($idtype, array('aid', 'tid', 'pid', 'uid')) && $ids) { $query = DB::query("SELECT * FROM %t WHERE %i IN (%n) %i", array($this->_table, $idtype, (array) $ids, $orderby)); while ($value = DB::fetch($query)) { $attachments[$value['aid']] = $value; $this->_tableids[$value['tableid']][] = $value['aid']; } } return $attachments; }
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_by_id_idtype($id, $idtype = '', $orderby = '', $ordersc = 'DESC', $start = 0, $limit = 0) { if (!$id) { return null; } $sql = array(DB::field('id', $id)); if ($idtype) { $sql[] = DB::field('idtype', $idtype); } $wheresql = implode(' AND ', $sql); if ($orderby = DB::order($orderby, $ordersc)) { $wheresql .= ' ORDER BY ' . $orderby; } if ($limit) { $wheresql .= DB::limit($start, $limit); } return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, $wheresql)); }
public function fetch_by_fid_dateline($fid, $dateline = 0, $order = 'dateline', $sort = 'DESC') { $parameter = array($this->_table); $wherearr = array(); $wheresql = ''; if ($fid) { $wherearr[] = 'fid=%d'; $parameter[] = $fid; } if ($dateline) { $wherearr[] = 'dateline=%d'; $parameter[] = $dateline; } if ($wherearr) { $wheresql = ' WHERE ' . implode(' AND ', $wherearr); } return DB::fetch_first('SELECT * FROM %t ' . $wheresql . ' ORDER BY ' . DB::order($order, $sort), $parameter, $this->_pk); }
public function select($tagid = 0, $itemid = 0, $idtype = '', $orderfield = '', $ordertype = 'DESC', $limit = 0, $count = 0, $itemidglue = '=', $returnnum = 0) { $data = self::make_where($tagid, $itemid, $idtype, $itemidglue); $ordersql = $limitsql = ''; if ($orderfield) { $ordersql = ' ORDER BY ' . DB::order($orderfield, $ordertype); } if ($limit) { $limitsql = DB::limit($limit, $count); } if ($data) { if ($returnnum) { return DB::result_first('SELECT count(*) FROM %t WHERE ' . $data['where'], $data['data']); } return DB::fetch_all('SELECT * FROM %t WHERE ' . $data['where'] . $ordersql . $limitsql, $data['data']); } else { return false; } }
public function fetch_all_by_uid_appid($uid = 0, $appid = 0, $order = null, $sort = 'DESC', $start = 0, $limit = 0) { $parameter = array($this->_table); $wherearr = array(); if ($uid) { $uid = dintval((array) $uid, true); $wherearr[] = 'uid IN(%n)'; $parameter[] = $uid; } if ($appid) { $appid = dintval((array) $appid, true); $wherearr[] = 'appid IN(%n)'; $parameter[] = $appid; } $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : ''; $sort = in_array($sort, array('DESC', 'ASC')) ? $sort : 'DESC'; $ordersql = $order !== null ? ' ORDER BY ' . DB::order($order, $sort) : ''; if (!$uid) { $limit = $limit ? $limit : 100; } return DB::fetch_all("SELECT * FROM %t {$wheresql} {$ordersql} " . DB::limit($start, $limit), $parameter); }
public function fetch_all_by_uid_doid($uids, $bannedids = '', $paramorderby = '', $startrow = 0, $items = 0, $status = true, $allfileds = false) { $parameter = array($this->_table); $orderby = $paramorderby && in_array($paramorderby, array('dateline', 'replynum')) ? 'ORDER BY ' . DB::order($paramorderby, 'DESC') : 'ORDER BY ' . DB::order('dateline', 'DESC'); $wheres = array(); if ($uids) { $parameter[] = $uids; $wheres[] = 'uid IN (%n)'; } if ($bannedids) { $parameter[] = $bannedids; $wheres[] = 'doid NOT IN (%n)'; } if ($status) { $wheres[] = ' status = 0'; } $wheresql = !empty($wheres) && is_array($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : ''; if (empty($wheresql)) { return null; } return DB::fetch_all('SELECT ' . ($allfileds ? '*' : 'doid') . ' FROM %t ' . $wheresql . ' ' . $orderby . DB::limit($startrow, $items), $parameter); }
public function fetch_all_search($uid, $vid, $flag = null, $username = '', $starttime = 0, $endtime = 0, $order = 'dateline', $start = 0, $limit = 0, $sort = 'DESC') { $condition = $this->search_condition($uid, $vid, $flag, $username, $starttime, $endtime); $ordersql = !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : ''; return DB::fetch_all("SELECT * FROM %t {$condition['0']} {$ordersql} " . DB::limit($start, $limit), $condition[1], $this->_pk); }
public function fetch_all_by_sortid($sortid, $order = '') { return DB::fetch_all('SELECT * FROM %t WHERE sortid=%d ' . ($order ? 'ORDER BY ' . DB::order('displayorder', $order) : ''), array($this->_table, $sortid), 'optionid'); }
function getranklist_picture($num = 20, $view = 'hot', $orderby = 'all') { $timestamp = TIMESTAMP - 86400; $dateline = 'p.' . DB::field('dateline', $timestamp, '>='); if ($orderby == 'thisweek') { $timestamp = TIMESTAMP - 604800; $dateline = 'p.' . DB::field('dateline', $timestamp, '>='); } elseif ($orderby == 'thismonth') { $timestamp = TIMESTAMP - 2592000; $dateline = 'p.' . DB::field('dateline', $timestamp, '>='); } $data = array(); $query = C::t('home_pic')->fetch_all_by_sql($dateline, 'p.' . DB::order($view, 'DESC'), 0, $num); require_once libfile('function/home'); $rank = 0; foreach ($query as $value) { ++$rank; $picture = array('picid' => $value['picid'], 'uid' => $value['uid'], 'username' => $value['username'], 'title' => $value['title'], 'filepath' => $value['filepath'], 'thumb' => $value['thumb'], 'remote' => $value['remote'], 'hot' => $value['hot'], 'sharetimes' => $value['sharetimes'], 'click1' => $value['click1'], 'click2' => $value['click2'], 'click3' => $value['click3'], 'click4' => $value['click4'], 'click5' => $value['click5'], 'click6' => $value['click6'], 'click7' => $value['click7'], 'click8' => $value['click8'], 'albumid' => $value['albumid'], 'albumname' => $value['albumname'], 'friend' => $value['friend']); $picture['rank'] = $rank; $picture['url'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', $picture['thumb'], $picture['remote']) : STATICURL . 'image/common/nopublish.gif'; $picture['origurl'] = pic_get($picture['filepath'], 'album', 0, $picture['remote']); $data[] = $picture; } return $data; }
public function range_by_uid($uid, $start = 0, $limit = 0, $orderby = '', $sort = '') { $orderby = in_array($orderby, array($this->_pk, 'uid'), true) ? $orderby : ''; return DB::fetch_all('SELECT * FROM %t WHERE uid = %d %i %i', array($this->_table, $uid, $orderby ? ' ORDER BY ' . DB::order($orderby, $sort) : '', DB::limit($start, $limit)), $this->_pk); }
public function range($start = 0, $limit = 0, $sort = '') { if ($sort) { $this->checkpk(); } return DB::fetch_all('SELECT * FROM ' . DB::table($this->_table) . ($sort ? ' ORDER BY ' . DB::order($this->_pk, $sort) : '') . DB::limit($start, $limit), null, $this->_pk ? $this->_pk : ''); }
public function fetch_all_by_classid($classid, $order = 'asc') { $result = DB::fetch_all('SELECT optionid, classid as classifiedTopId,title as classifiedTitle,identifier as classifiedName,type as classifiedType,rules as classifiedRules FROM %t WHERE ' . DB::field('classid', $classid) . ($order ? 'ORDER BY ' . DB::order('displayorder', $order) : ''), array($this->_table)); return $result; }
public function fetch_all_new_post_by_pid($pid, $start = 0, $limit = 0, $tableid = 0, $glue = '>', $sort = 'ASC') { return $limit ? DB::fetch_all('SELECT * FROM ' . DB::table($this->get_tablename($tableid)) . ' WHERE ' . DB::field('pid', $pid, $glue) . ' ORDER BY ' . DB::order('pid', $sort) . DB::limit($start, $limit), $this->_pk) : array(); }
public function fetch_all_by_targetuid_action($uid, $action, $start, $limit, $order = 'DESC') { return DB::fetch_all('SELECT * FROM %t WHERE targetuid=%d AND action=%d ' . ($order ? 'ORDER BY ' . DB::order('dateline', $order) : '') . ' ' . ($limit ? DB::limit($start, $limit) : ''), array($this->_table, $uid, $action)); }
public function fetch_all_by_radminid($radminid, $glue = '>', $orderby = 'type') { $ordersql = ''; if ($ordersql = DB::order($orderby, 'DESC')) { $ordersql = ' ORDER BY ' . $ordersql; } return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, DB::field('radminid', intval($radminid), $glue) . $ordersql), 'groupid'); }
public function range_by_field($start = 0, $limit = 0, $orderby = '', $sort = '') { $orderby = in_array($orderby, array('extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8', 'friends', 'posts', 'threads', 'oltime', 'digestposts', 'doings', 'blogs', 'albums', 'sharings', 'attachsize', 'views', 'todayattachs', 'todayattachsize', 'follower', 'following', 'newfollower', 'feeds'), true) ? $orderby : ''; return DB::fetch_all('SELECT * FROM ' . DB::table($this->_table) . ($orderby ? ' ORDER BY ' . DB::order($orderby, $sort) : '') . DB::limit($start, $limit), null, $this->_pk); }
public function fetch_all_stat_memberlist($username, $orderby = '', $sort = '', $start = 0, $limit = 0) { $orderby = in_array($orderby, array('uid', 'credits', 'regdate', 'gender', 'username', 'posts', 'lastvisit'), true) ? $orderby : 'uid'; $sql = ''; $sql = !empty($username) ? " WHERE username LIKE '" . addslashes(stripsearchkey($username)) . "%'" : ''; $memberlist = array(); $query = DB::query("SELECT m.uid, m.username, mp.gender, m.email, m.regdate, ms.lastvisit, mc.posts, m.credits\n\t\t\tFROM " . DB::table($this->_table) . " m\n\t\t\tLEFT JOIN " . DB::table('common_member_profile') . " mp ON mp.uid=m.uid\n\t\t\tLEFT JOIN " . DB::table('common_member_status') . " ms ON ms.uid=m.uid\n\t\t\tLEFT JOIN " . DB::table('common_member_count') . " mc ON mc.uid=m.uid\n\t\t\t{$sql} ORDER BY " . DB::order($orderby, $sort) . DB::limit($start, $limit)); while ($member = DB::fetch($query)) { $member['usernameenc'] = rawurlencode($member['username']); $member['regdate'] = dgmdate($member['regdate']); $member['lastvisit'] = dgmdate($member['lastvisit']); $memberlist[$member['uid']] = $member; } return $memberlist; }
public function fetch_all_by_special($special, $authorid = 0, $replies = 0, $displayorder = null, $subject = '', $join = 0, $start = 0, $limit = 0, $order = 'dateline', $sort = 'DESC') { $condition = $this->make_special_condition($special, $authorid, $replies, $displayorder, $subject, $join, 0); $ordersql = !empty($order) ? ' ORDER BY t.' . DB::order($order, $sort) : ''; return DB::fetch_all("SELECT t.* FROM %t t {$condition['jointable']} " . $condition['where'] . $ordersql . DB::limit($start, $limit), $condition['parameter'], $this->_pk); }
public function fetch_all_for_search($aids, $orderby = '', $ascdesc = '', $start = 0, $limit = 0) { return DB::fetch_all("SELECT at.*,ac.viewnum, ac.commentnum FROM " . DB::table($this->_table) . " at LEFT JOIN " . DB::table('portal_article_count') . " ac ON at.aid=ac.aid WHERE at." . DB::field('aid', $aids) . ($orderby ? " ORDER BY " . DB::order($orderby, $ascdesc) : ' ') . DB::limit($start, $limit)); }
public function fetch_all_by_flag($flag, $glue = '=', $sort = 'ASC') { $glue = helper_util::check_glue($glue); return DB::fetch_all("SELECT * FROM %t WHERE flag{$glue}%d ORDER BY " . DB::order('displayorder', $sort), array($this->_table, $flag), $this->_pk); }
public function range_by_field($start = 0, $limit = 0, $orderby = '', $sort = '') { $orderby = in_array($orderby, array('thismonth', 'total', 'lastupdate'), true) ? $orderby : ''; return DB::fetch_all('SELECT * FROM ' . DB::table($this->_table) . ($orderby ? ' WHERE ' . $orderby . ' >0 ORDER BY ' . DB::order($orderby, $sort) : '') . ' ' . DB::limit($start, $limit), null, $this->_pk); }