예제 #1
0
 public function count_by_wherec($condition)
 {
     if (is_array($condition)) {
         $where = " AND " . implode($condition, ' AND ');
     }
     return XDB::result_first("SELECT COUNT(*) FROM %t WHERE 1 %i", array($this->_table, $where));
 }
 public function count_by_fid($fids)
 {
     if (empty($fids)) {
         return 0;
     }
     return XDB::result_first('SELECT COUNT(*) FROM %t WHERE ' . XDB::field('fid', $fids), array($this->_table));
 }
예제 #3
0
 public function fetch_groupnum_by_founderuid($uid)
 {
     if (empty($uid)) {
         return false;
     }
     return XDB::result_first("SELECT COUNT(*) FROM " . XDB::table($this->_table) . " WHERE founderuid=%d", array($uid));
 }
예제 #4
0
 public function fetch_all_username_by_uid($uid)
 {
     $user = '';
     if ($uid) {
         $user = XDB::result_first('SELECT username FROM %t WHERE uid=%s', array($this->_table, $uid));
     }
     return $user;
 }
예제 #5
0
 public function fetch_count()
 {
     return XDB::result_first("SELECT count(*) FROM " . XDB::table('forum_grouplevel'));
 }
예제 #6
0
 public function check_variable($pluginid, $variable)
 {
     return XDB::result_first("SELECT COUNT(*) FROM %t WHERE pluginid=%d AND variable=%s", array($this->_table, $pluginid, $variable));
 }
예제 #7
0
 public function result_level_by_id($id)
 {
     return XDB::result_first("SELECT level FROM %t WHERE id=%d", array($this->_table, $id));
 }
예제 #8
0
 public function fetch_groupname_by_order($order)
 {
     return XDB::result_first("SELECT groupname FROM %t WHERE `order` = %d ", array($this->_table, $order));
 }
예제 #9
0
 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}");
 }
예제 #10
0
 public function get_total_filesize()
 {
     $attachsize = 0;
     for ($i = 0; $i < 10; $i++) {
         $attachsize += XDB::result_first("SELECT SUM(filesize) FROM " . XDB::table('forum_attachment_' . $i));
     }
     return $attachsize;
 }
 public function fetch_by_modename($modename, $bid)
 {
     return XDB::result_first("SELECT %i FROM %t WHERE bid='%i'", array($modename, $this->_table, $bid));
 }
예제 #12
0
 public function count_by_id_idtype($id, $idtype)
 {
     return XDB::result_first("SELECT COUNT(*) FROM %t WHERE id=%d AND idtype=%s", array($this->_table, $id, $idtype));
 }
 public function getid_by_keyword($keyword)
 {
     return XDB::result_first("SELECT id FROM %t WHERE keyword=%s", array($this->_table, $keyword));
 }
예제 #14
0
 public function fetch_max_tid()
 {
     return XDB::result_first("SELECT MAX(tid) as maxtid FROM " . XDB::table('forum_thread'));
 }
예제 #15
0
 public function count_by_tid_post($tableid, $tid)
 {
     return XDB::result_first('SELECT COUNT(*) FROM %t WHERE tid=%d AND invisible=0 AND first=0', array(self::get_tablename($tableid), $tid));
 }
예제 #16
0
 public function getvoter_by_tid($tid)
 {
     return XDB::result_first("SELECT COUNT(*) FROM %t WHERE tid=%d", array($this->_table, $tid));
 }
예제 #17
0
 public function count_by_tid_magicid($tid, $magicid)
 {
     return XDB::result_first('SELECT COUNT(*) FROM %t WHERE tid=%d AND magicid=%d', array($this->_table, $tid, $magicid));
 }
 public function fetch_by_aid($uid, $aid)
 {
     return XDB::result_first("SELECT attachment FROM %t WHERE uid=%d and aid=%d and isimage=1", array($this->_table, $uid, $aid));
 }
예제 #19
0
 public function gettagid_by_tagname($tagname)
 {
     return XDB::result_first("SELECT tagid FROM %t WHERE tagname='%i'", array($this->_table, $tagname));
 }
예제 #20
0
 public function getstar_by_tid_uid($uid, $tid)
 {
     return XDB::result_first("SELECT star FROM %t WHERE tid=%d and uid=%d", array($this->_table, $tid, $uid));
 }
예제 #21
0
 public function count()
 {
     $count = (int) XDB::result_first("SELECT count(*) FROM " . XDB::table($this->_table));
     return $count;
 }
예제 #22
0
 public function count_by_where($where)
 {
     return XDB::result_first("SELECT COUNT(*) FROM %t WHERE 1 %i", array($this->_table, $where));
 }
예제 #23
0
 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));
 }
예제 #24
0
 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 fix_get_block($hash)
 {
     return XDB::result_first("SELECT * FROM %t WHERE hash=%s", array($this->_blockstyletable, $hash));
 }