예제 #1
0
 public function fetch_by_id_idtype($id, $idtype, $uid = 0)
 {
     if ($uid) {
         $uidsql = ' AND ' . XDB::field('uid', $uid);
     }
     return XDB::fetch_first("SELECT * FROM %t WHERE id=%d AND idtype=%s {$uidsql}", array($this->_table, $id, $idtype));
 }
예제 #2
0
 public function fetch_userinfo($uid, $fid)
 {
     if (empty($uid) || empty($fid)) {
         return array();
     }
     return XDB::fetch_first("SELECT * FROM %t WHERE fid=%d AND uid=%d", array($this->_table, $fid, $uid));
 }
예제 #3
0
 public function fetch_by_username($username)
 {
     $user = array();
     if ($username) {
         $user = XDB::fetch_first('SELECT * FROM %t WHERE username=%s', array($this->_table, $username));
     }
     return $user;
 }
예제 #4
0
 public function check_moderator_for_uid($fid, $uid, $accessmasks = 0)
 {
     if (!intval($fid) || !intval($uid)) {
         return false;
     }
     if ($accessmasks) {
         $accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowgetimage, a.allowpostattach';
         $accessadd2 = "LEFT JOIN " . XDB::table('forum_access') . " a ON a." . XDB::field('uid', $uid) . " AND a." . XDB::field('fid', $fid);
     }
     return XDB::fetch_first("SELECT ff.postperm, m.uid AS istargetmod {$accessadd1}\n\t\t\t\tFROM " . XDB::table($this->_table) . " ff\n\t\t\t\t{$accessadd2}\n\t\t\t\tLEFT JOIN " . XDB::table('forum_moderator') . " m ON m.fid=%d AND m.uid=%d\n\t\t\t\tWHERE ff.fid=%d", array($fid, $uid, $fid));
 }
예제 #5
0
 public function fetch($id, $force_from_db = false)
 {
     $data = array();
     if (!empty($id)) {
         if ($force_from_db || ($data = $this->fetch_cache($id)) === false) {
             $data = XDB::fetch_first('SELECT * FROM ' . XDB::table($this->_table) . ' WHERE ' . XDB::field($this->_pk, $id));
             if (!empty($data)) {
                 $this->store_cache($id, $data);
             }
         }
     }
     return $data;
 }
 public function fetch_by_bid($bid)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE bid='%i'", array($this->_table, $bid));
 }
예제 #7
0
 public function get_by_cateidanduid($uid, $cateid)
 {
     return XDB::fetch_first("SELECT * FROM %t where uid=%d,cateid=%d", array($this->_table, $uid, $cateid));
 }
 public function get_by_id($helpid)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE flid=%d", array($this->_table, $helpid));
 }
예제 #9
0
 public function get_by_diystyleid($diystyleid)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE diystyleid=%d", array($this->_table, $diystyleid));
 }
예제 #10
0
 public function fetch_by_credits($credits = 0)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE creditshigher<=%d AND %d<creditslower LIMIT 1", array($this->_table, $credits, $credits));
 }
예제 #11
0
 public function show_table_by_tableid($tableid)
 {
     return XDB::fetch_first('SHOW CREATE TABLE %t', array(self::get_tablename($tableid)));
 }
예제 #12
0
 public function fetch_max_image($tableid, $idtype, $id)
 {
     return $this->_check_id($idtype, $id) ? XDB::fetch_first('SELECT * FROM %t WHERE %i AND isimage IN (1, -1) ORDER BY width DESC LIMIT 1', array($this->_get_table($tableid), XDB::field($idtype, $id))) : array();
 }
예제 #13
0
 public function fetch_mfandtag_by_groupid($groupid)
 {
     return XDB::fetch_first("SELECT ismf,istag FROM %t WHERE groupid=%d", array($this->_table, $groupid));
 }
 public function fetch_all()
 {
     return XDB::fetch_first("SELECT * FROM %t ", array($this->_table));
 }
예제 #15
0
 function get_forum_by_fid($fid, $field = '', $table = 'forum')
 {
     static $forumlist = array('forum' => array(), 'forumfield' => array());
     $table = $table != 'forum' ? 'forumfield' : 'forum';
     $return = array();
     if (!array_key_exists($fid, $forumlist[$table])) {
         $forumlist[$table][$fid] = XDB::fetch_first("SELECT * FROM " . XDB::table('forum_' . $table) . " WHERE fid=%d", array($fid));
         if (!is_array($forumlist[$table][$fid])) {
             $forumlist[$table][$fid] = array();
         }
     }
     if (!empty($field)) {
         $return = isset($forumlist[$table][$fid][$field]) ? $forumlist[$table][$fid][$field] : null;
     } else {
         $return = $forumlist[$table][$fid];
     }
     return $return;
 }
예제 #16
0
 public function fetch_by_tid_magicid($tid, $magicid = 0)
 {
     return XDB::fetch_first('SELECT * FROM %t WHERE tid=%d AND magicid=%d', array($this->_table, $tid, $magicid));
 }
예제 #17
0
 public function userget_by_albumid($albumid, $uid)
 {
     return XDB::fetch_first("SELECT * FROM %t\n\t\tWHERE albumid=%d AND uid=%d order by displayorder", array($this->_table, $albumid, $uid));
 }
예제 #18
0
 function gettablestatus($tableid = 0)
 {
     $table_info = XDB::fetch_first("SHOW TABLE STATUS LIKE '" . str_replace('_', '\\_', XDB::table($this->get_table_name($tableid))) . "'");
     $table_info['Data_length'] = $table_info['Data_length'] / 1024 / 1024;
     $nums = intval(log($table_info['Data_length']) / log(10));
     $digits = 0;
     if ($nums <= 3) {
         $digits = 3 - $nums;
     }
     $table_info['Data_length'] = number_format($table_info['Data_length'], $digits) . ' MB';
     $table_info['Index_length'] = $table_info['Index_length'] / 1024 / 1024;
     $nums = intval(log($table_info['Index_length']) / log(10));
     $digits = 0;
     if ($nums <= 3) {
         $digits = 3 - $nums;
     }
     $table_info['Index_length'] = number_format($table_info['Index_length'], $digits) . ' MB';
     return $table_info;
 }
예제 #19
0
 public function getmsg_by_msgid($msgid)
 {
     return XDB::fetch_first("SELECT m.*,b.name as brandname FROM %t as m\n\t\tLEFT JOIN %t as b ON m.bid = b.bid\n\t\tWHERE msgid=%d", array($this->_table, $this->_jointable, $msgid));
 }
예제 #20
0
 public function getvotetotal_by_bid($bid)
 {
     $votedata = XDB::fetch_first("SELECT (star1 * 1 + star2 * 2 + star3 * 3 + star4 * 4 + star5 * 5) as total,(star1  + star2  + star3   + star4   + star5 ) as totalnum FROM %t where bid=%d", array($this->_table, $bid));
     $total = array(0.0, 0, 0, 0);
     if ($votedata) {
         $total = $votedata['total'] / $votedata['totalnum'];
         $total = sprintf("%1.1f", $total);
         $vt = $total / 5 * 100;
         $vt = sprintf("%1.0f", $vt);
         return array($total, $votedata['total'], $votedata['totalnum'], $vt);
     }
     return $total;
 }
 public function userget_by_catid($catid, $uid)
 {
     return XDB::fetch_first("SELECT c.*,m.username,b.name as brandname FROM %t as c\n\t\tLEFT JOIN %t as m ON c.uid = m.uid\t\n\t\tLEFT JOIN %t as b ON b.bid = c.bid\t\t\n\t\tWHERE c.catid=%d and c.uid =%d order by c.displayorder", array($this->_table, $this->_membertable, $this->_joinbrandtable, $catid, $uid));
 }
예제 #22
0
 public function fetch_first_by_name($name, $upid)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE " . XDB::field('name', $name) . " and upid=%d", array($this->_table, $upid));
 }
예제 #23
0
 public function fetch_firstbyaid($aid)
 {
     return XDB::fetch_first("SELECT * FROM %t WHERE aid=%d ", array($this->_table, $aid));
 }
 public function usergetmaxalbumcategory_by_bid($bid, $uid)
 {
     return XDB::fetch_first("SELECT g.maxalbumcategory, g.maxalbum FROM %t as t \n\t\tLEFT JOIN %t as g on t.groupid=g.groupid \n\t\twhere t.bid=%d and t.uid=%d", array($this->_table, $this->_grouptable, $bid, $uid));
 }