public function fetch_all_by_searchc($condition, $orderby, $start = 0, $ppp = 0) { if (is_array($condition)) { $where = " AND " . implode($condition, ' AND '); } return XDB::fetch_all("SELECT * FROM %t WHERE 1 %i ORDER BY %i LIMIT %d, %d", array($this->_table, $where, $orderby, $start, $ppp)); }
public function fetch_all_by_name($name) { if (!empty($name)) { return XDB::fetch_all('SELECT * FROM %t WHERE ' . XDB::field('name', $name), array($this->_table)); } return array(); }
public function fetch_all_by_fid($fids) { if (empty($fids)) { return array(); } return XDB::fetch_all('SELECT * FROM %t WHERE ' . XDB::field('fid', $fids), array($this->_table)); }
public function fetch_all() { $retdata = array(); foreach (XDB::fetch_all("SELECT langkey,langvalue FROM %t WHERE 1", array($this->_table)) as $key => $value) { $retdata[$value['langkey']] = $value['langvalue']; } return $retdata; }
public function fetch_all_by_id_idtype($id, $idtype, $start = 0, $limit = 0) { $parameter = array($this->_table, $this->_membertable); $wherearr = array(); $parameter[] = $id; $wherearr[] = "f.id=%d"; if (!empty($idtype)) { $parameter[] = $idtype; $wherearr[] = "f.idtype=%s"; } $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : ''; return XDB::fetch_all("SELECT f.*,m.username FROM %t as f\n\t\t LEFT JOIN %t as m ON f.uid = m.uid\t\t\n\t\t {$wheresql} ORDER BY f.dateline DESC " . XDB::limit($start, $limit), $parameter, $this->_pk); }
public function fetch_all_forblock($where, $orderby, $ordersc, $itemsnum) { return XDB::fetch_all("SELECT * FROM %t %i ORDER BY %i %i %i", array($this->_table, $where, $orderby, $ordersc, $itemsnum)); }
public function fetch_all() { return XDB::fetch_all("SELECT * FROM %t\t", array($this->_table)); }
public function fetch_all_field_perm() { return XDB::fetch_all("SELECT fid, viewperm, postperm, replyperm, getattachperm, postattachperm, postimageperm FROM " . XDB::table($this->_table) . " WHERE founderuid=0"); }
public function fetch_all_creditslower_order() { return XDB::fetch_all("SELECT * FROM " . XDB::table('forum_grouplevel') . " WHERE 1 ORDER BY creditslower"); }
public function fetch_all_by_order($order) { return XDB::fetch_all("SELECT * FROM %t WHERE `order`>%d ORDER BY `order` ", array($this->_table, $order)); }
public function getusermenu($istop = 0) { return XDB::fetch_all("SELECT * FROM %t WHERE 1 and status=1 and istop=%d ORDER BY displayorder ", array($this->_table, $istop)); }
public function fetch_all_by_pid_width($tableid, $pids, $width) { return XDB::fetch_all("SELECT * FROM %t WHERE %i AND isimage IN ('1', '-1') AND width>=%d", array($this->_get_table($tableid), XDB::field('pid', $pids), $width)); }
public function fetch_all_for_grouplist($orderby = 'displayorder', $fieldarray = array(), $num = 1, $fids = array(), $sort = 0, $getcount = 0) { if ($fieldarray && is_array($fieldarray)) { $fieldadd = ''; foreach ($fieldarray as $field) { $fieldadd .= $field . ', '; } } else { $fieldadd = 'ff.*, '; } $start = 0; if (is_array($num)) { list($start, $snum) = $num; } else { $snum = $num; } $orderbyarray = array('displayorder' => 'f.displayorder DESC', 'dateline' => 'ff.dateline DESC', 'lastupdate' => 'ff.lastupdate DESC', 'membernum' => 'ff.membernum DESC', 'thread' => 'f.threads DESC', 'activity' => 'f.commoncredits DESC'); $useindex = $orderby == 'displayorder' ? 'USE INDEX(fup_type)' : ''; $orderby = !empty($orderby) && $orderbyarray[$orderby] ? "ORDER BY " . $orderbyarray[$orderby] : ''; $limitsql = $num ? "LIMIT {$start}, {$snum} " : ''; $field = $sort ? 'fup' : 'fid'; $fids = $fids && is_array($fids) ? 'f.' . $field . ' IN (' . dimplode($fids) . ')' : ''; if (empty($fids)) { $levelsql = " AND f.level>'-1'"; } $fieldsql = $fieldadd . ' f.fid, f.name, f.threads, f.posts, f.todayposts, f.level as flevel '; if ($getcount) { return XDB::result_first("SELECT count(*) FROM " . XDB::table($this->_table) . " f {$useindex} WHERE" . ($fids ? " {$fids} AND " : '') . " f.type='sub' AND f.status=3 {$levelsql}"); } return XDB::fetch_all("SELECT {$fieldsql} FROM " . XDB::table($this->_table) . " f {$useindex} LEFT JOIN " . XDB::table("forum_forumfield") . " ff ON ff.fid=f.fid WHERE" . ($fids ? " {$fids} AND " : '') . " f.type='sub' AND f.status=3 {$levelsql} {$orderby} {$limitsql}"); }
public function fetch_all_mf() { return XDB::fetch_all("SELECT * FROM %t ORDER BY displayorder", array($this->_table)); }
public function getuid_by_bid($bid) { return XDB::fetch_all("SELECT uid FROM %t WHERE bid=%d", array($this->_table, $bid)); }
public function fetch_all_by_searchc($condition, $orderby, $start = 0, $ppp = 0) { if (is_array($condition)) { $where = " AND " . implode($condition, ' AND '); } return XDB::fetch_all("SELECT a.*,b.name FROM %t as a\n\t\tLEFT JOIN %t as b ON a.bid = b.bid\n\t\tWHERE 1 %i ORDER BY %i LIMIT %d, %d", array($this->_table, $this->_joinbrandtable, $where, $orderby, $start, $ppp)); }
public function fetch_all_by_pluginid($pluginid) { return XDB::fetch_all("SELECT * FROM %t WHERE pluginid=%d ORDER BY displayorder", array($this->_table, $pluginid)); }
public function fetch_all_for_guide($type, $limittid, $tids = array(), $heatslimit = 3, $dateline = 0) { switch ($type) { case 'hot': $addsql = ' AND heats>' . intval($heatslimit); break; case 'digest': $addsql = ' AND digest>0'; break; default: $addsql = ''; } if (getglobal('setting/followforumid')) { $addsql .= ' AND ' . XDB::field('fid', getglobal('setting/followforumid'), '<>'); } $tidsql = ''; if ($tids) { $tids = dintval($tids, true); $tidsql = XDB::field('tid', $tids); } else { $tidsql = 'tid>' . intval($limittid); if ($dateline) { $addsql .= ' AND dateline > ' . intval($dateline); } $addsql .= ' AND displayorder>=0 ORDER BY lastpost DESC LIMIT 600'; } return XDB::fetch_all("SELECT * FROM " . XDB::table('forum_thread') . " WHERE " . $tidsql . $addsql); }
public function fetch_all_recyclebin_by_dateline($dateline, $start = 0, $limit = 0) { return XDB::fetch_all("SELECT tm.tid FROM %t tm, %t t WHERE tm.action='DEL' AND tm.dateline<%d AND t.tid=tm.tid AND t.displayorder=-1" . XDB::limit($start, $limit), array($this->_table, 'forum_thread', $dateline)); }
public function fetch_all_new_post_by_pid($pid, $start = 0, $limit = 0, $tableid = 0, $glue = '>', $sort = 'ASC') { return $limit ? XDB::fetch_all('SELECT * FROM ' . XDB::table($this->get_tablename($tableid)) . ' WHERE ' . XDB::field('pid', $pid, $glue) . ' ORDER BY ' . XDB::order('pid', $sort) . XDB::limit($start, $limit), $this->_pk) : array(); }
public function range($start = 0, $limit = 0, $sort = '') { if ($sort) { $this->checkpk(); } return XDB::fetch_all('SELECT * FROM ' . XDB::table($this->_table) . ($sort ? ' ORDER BY ' . XDB::order($this->_pk, $sort) : '') . XDB::limit($start, $limit), null, $this->_pk ? $this->_pk : ''); }
public function fetch_all_group_for_user($uid, $count = 0, $ismanager = 0, $start = 0, $num = 0) { $uid = intval($uid); if (empty($uid)) { return array(); } if (empty($ismanager)) { $levelsql = ''; } elseif ($ismanager == 1) { $levelsql = ' AND level IN(1,2)'; } elseif ($ismanager == 2) { $levelsql = ' AND level IN(3,4)'; } if ($count == 1) { return XDB::result_first("SELECT count(*) FROM " . XDB::table('forum_groupuser') . " WHERE uid='{$uid}' {$levelsql}"); } empty($start) && ($start = 0); empty($num) && ($num = 100); return XDB::fetch_all("SELECT fid, level FROM " . XDB::table('forum_groupuser') . " WHERE uid='{$uid}' {$levelsql} ORDER BY lastupdate DESC " . XDB::limit($start, $num)); }
public function fetch_all_by_searchd($condition, $orderby) { if (is_array($condition)) { $where = " AND " . implode($condition, ' AND '); } return XDB::fetch_all("SELECT * FROM %t WHERE 1 %i ORDER BY %i", array($this->_table, $where, $orderby)); }
public function fetch_all_by_toupid($upid) { return XDB::fetch_all('SELECT * FROM %t WHERE 1 and enabled=1 and upid=%d', array($this->_table, $upid)); }
public function fetch_all_for_manage($tableid, $inforum = '', $authorid = 0, $filename = '', $keyword = '', $sizeless = 0, $sizemore = 0, $dlcountless = 0, $dlcountmore = 0, $daysold = 0, $count = 0, $start = 0, $limit = 0) { $sql = "1"; if (!is_numeric($tableid) || $tableid < 0 || $tableid > 9) { return; } if ($inforum) { $sql .= is_numeric($inforum) ? " AND t.fid=" . XDB::quote($inforum) : ''; $sql .= $inforum == 'isgroup' ? ' AND t.isgroup=\'1\'' : ' AND t.isgroup=\'0\''; } if ($authorid) { $sql .= " AND a.uid=" . XDB::quote($authorid); } if ($filename) { $sql .= " AND a.filename LIKE " . XDB::quote('%' . $filename . '%'); } if ($keyword) { $sqlkeywords = $or = ''; foreach (explode(',', str_replace(' ', '', $keyword)) as $keyword) { $sqlkeywords .= " {$or} a.description LIKE " . XDB::quote('%' . $keyword . '%'); $or = 'OR'; } $sql .= " AND ({$sqlkeywords})"; } $sql .= $sizeless ? " AND a.filesize>'{$sizeless}'" : ''; $sql .= $sizemore ? " AND a.filesize<'{$sizemore}' " : ''; $sql .= $dlcountless ? " AND ai.downloads<'{$dlcountless}'" : ''; $sql .= $dlcountmore ? " AND ai.downloads>'{$dlcountmore}'" : ''; $sql .= $daysold ? " AND a.dateline<'" . (TIMESTAMP - intval($daysold) * 86400) . "'" : ''; if ($count) { return XDB::result_first("SELECT COUNT(*)\n\t\t\t\tFROM " . XDB::table('forum_attachment_' . $tableid) . " a\n\t\t\t\tINNER JOIN " . XDB::table('forum_attachment') . " ai USING(aid)\n\t\t\t\tINNER JOIN " . XDB::table('forum_thread') . " t\n\t\t\t\tINNER JOIN " . XDB::table('forum_forum') . " f\n\t\t\t\tWHERE t.tid=a.tid AND f.fid=t.fid AND t.displayorder>='0' AND {$sql}"); } return XDB::fetch_all("SELECT a.*, ai.downloads, t.fid, t.tid, t.subject, f.name AS fname\n\t\t\t\tFROM " . XDB::table('forum_attachment_' . $tableid) . " a\n\t\t\t\tINNER JOIN " . XDB::table('forum_attachment') . " ai USING(aid)\n\t\t\t\tINNER JOIN " . XDB::table('forum_thread') . " t\n\t\t\t\tINNER JOIN " . XDB::table('forum_forum') . " f\n\t\t\t\tWHERE t.tid=a.tid AND f.fid=t.fid AND t.displayorder>='0' AND {$sql} ORDER BY a.aid DESC " . XDB::limit($start, $limit)); }
public function fetch_all_forblock($where, $orderby, $ordersc, $itemsnum) { return XDB::fetch_all("SELECT t.*,tt.views,c.name as catename FROM %t AS t \n\t\tLEFT JOIN %t AS c ON t.cateid=c.cateid \n\t\tLEFT JOIN %t AS tt ON t.tid=tt.tid %i ORDER BY %i %i %i", array($this->_table, $this->_jointable, $this->_threadtable, $where, $orderby, $ordersc, $itemsnum)); }