public function update_by_threadtableid($threadtableid, $data, $unbuffered = false, $low_priority = false) { if (empty($data)) { return false; } return XDB::update($this->_table, $data, XDB::field('threadtableid', $threadtableid), $unbuffered, $low_priority); }
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 delete_by_variable($pluginid, $variable) { if (!$pluginid || !$variable) { return; } XDB::delete($this->_table, XDB::field('pluginid', $pluginid) . ' AND ' . XDB::field('variable', $variable)); }
public function delete_by_tid($tids) { $tids = dintval($tids, true); if ($tids) { return XDB::delete($this->_table, XDB::field('tid', $tids)); } return 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)); }
public function clear() { require_once libfile('function/forum'); $delaids = array(); $query = XDB::query("SELECT aid, attachment, thumb FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400))); while ($attach = XDB::fetch($query)) { dunlink($attach); $delaids[] = $attach['aid']; } if ($delaids) { XDB::query("DELETE FROM %t WHERE %i", array('forum_attachment', XDB::field('aid', $delaids)), false, true); XDB::query("DELETE FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400)), false, true); } }
public function srdelete($val, $condition = '', $unbuffered = false) { $ret = false; if (isset($val)) { $this->checkpk(); $where = ''; if (empty($condition)) { $where = XDB::field($this->_pk, $val); } elseif (is_array($condition)) { $where = XDB::field($this->_pk, $val) . ' AND ' . self::implode($condition, ' AND '); } else { $where = XDB::field($this->_pk, $val) . ' AND ' . $condition; } $ret = XDB::delete($this->_table, $where, null, $unbuffered); $this->clear_cache($val); } return $ret; }
public function update_by_bid($bid, $data) { return XDB::update($this->_table, $data, XDB::field('bid', $bid)); }
public function update_by_groupid($groupid, $data) { return XDB::update($this->_table, $data, XDB::field('groupid', $groupid)); }
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)); }
public function fetch_all_prune_by_search($tableid, $isgroup = null, $keywords = null, $message_length = null, $fid = null, $authorid = null, $starttime = null, $endtime = null, $useip = null, $outmsg = true, $start = null, $limit = null) { $sql = ''; $sql .= $fid ? ' AND p.' . XDB::field('fid', $fid) : ''; $sql .= $isgroup ? ' AND t.' . XDB::field('isgroup', $isgroup) : ''; $sql .= $authorid !== null ? ' AND p.' . XDB::field('authorid', $authorid) : ''; $sql .= $starttime ? ' AND p.' . XDB::field('dateline', $starttime, '>=') : ''; $sql .= $endtime ? ' AND p.' . XDB::field('dateline', $endtime, '<') : ''; $sql .= $useip ? ' AND p.' . XDB::field('useip', $useip, 'like') : ''; $sql .= $message_length !== null ? ' AND LENGTH(p.message) < ' . intval($message_length) : ''; $postlist = array(); if (trim($keywords)) { $sqlkeywords = ''; $or = ''; $keywords = explode(',', str_replace(' ', '', $keywords)); for ($i = 0; $i < count($keywords); $i++) { if (preg_match("/\\{(\\d+)\\}/", $keywords[$i])) { $keywords[$i] = preg_replace("/\\\\{(\\d+)\\\\}/", ".{0,\\1}", preg_quote($keywords[$i], '/')); $sqlkeywords .= " {$or} p.subject REGEXP '" . $keywords[$i] . "' OR p.message REGEXP '" . $keywords[$i] . "'"; } else { $keywords[$i] = addslashes($keywords[$i]); $sqlkeywords .= " {$or} p.subject LIKE '%" . $keywords[$i] . "%' OR p.message LIKE '%" . $keywords[$i] . "%'"; } $or = 'OR'; } $sql .= " AND ({$sqlkeywords})"; } if ($sql) { if ($isgroup) { $query = XDB::query('SELECT p.*, t.* FROM %t p LEFT JOIN %t t USING(tid) WHERE 1 %i %i', array(self::get_tablename($tableid), 'forum_thread', $sql, XDB::limit($start, $limit))); } else { $query = XDB::query('SELECT * FROM %t p WHERE 1 %i %i', array(self::get_tablename($tableid), $sql, XDB::limit($start, $limit))); } while ($post = XDB::fetch($query)) { if (!$outmsg) { unset($post['message']); } $postlist[$post[$this->_pk]] = $post; } } return $postlist; }
function fixalbum($bid, $data) { if (!is_array($data) || empty($data)) { return null; } $condition = array(); $bid = dintval($bid, true); $condition[] = XDB::field('bid', $bid); return XDB::update($this->_table, $data, implode(' AND ', $condition)); }
public function fetch_all($ids, $force_from_db = false) { $data = array(); if (!empty($ids)) { if ($force_from_db || ($data = $this->fetch_cache($ids)) === false || count($ids) != count($data)) { if (is_array($data) && !empty($data)) { $ids = array_diff($ids, array_keys($data)); } if ($data === false) { $data = array(); } if (!empty($ids)) { $query = XDB::query('SELECT * FROM ' . XDB::table($this->_table) . ' WHERE ' . XDB::field($this->_pk, $ids)); while ($value = XDB::fetch($query)) { $data[$value[$this->_pk]] = $value; $this->store_cache($value[$this->_pk], $value); } } } } return $data; }
public function delete_by_module($module) { XDB::delete($this->_table, XDB::field('module', $module)); }
public function delete_by_tid($tids) { return !empty($tids) ? XDB::delete($this->_table, XDB::field('tid', $tids)) : false; }
public function move_thread_by_tid($tids, $source, $target) { $source = intval($source); $target = intval($target); if ($source != $target) { XDB::query('REPLACE INTO %t SELECT * FROM %t WHERE tid IN (%n)', array($this->get_table_name($target), $this->get_table_name($source), $tids)); return XDB::delete($this->get_table_name($source), XDB::field('tid', $tids)); } else { return false; } }
public function delete_by_bids($bids) { XDB::delete($this->_table, XDB::field('bid', $bids)); }
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 update_for_user($uid, $fid, $threads = null, $replies = null, $level = null) { if (empty($uid) || empty($fid)) { return array(); } $sqladd = $threads !== null ? 'threads=' . intval($threads) : ''; if ($replies !== null) { $sqladd .= ($sqladd ? ', ' : '') . 'replies=' . intval($replies); } if ($level !== null) { $sqladd .= ($sqladd ? ', ' : '') . 'level=' . intval($level); } XDB::query("UPDATE %t SET {$sqladd} WHERE fid=%d AND " . XDB::field('uid', $uid), array($this->_table, $fid)); }
public function delete($val, $unbuffered = false, $uid = 0) { $val = dintval($val, is_array($val) ? true : false); if ($val) { if ($uid) { $uid = dintval($uid, is_array($uid) ? true : false); } return XDB::delete($this->_table, XDB::field($this->_pk, $val) . ($uid ? ' AND ' . XDB::field('uid', $uid) : ''), null, $unbuffered); } return !$unbuffered ? 0 : false; }
public function validate_level_for_group($fids) { if (empty($fids)) { return false; } XDB::query("UPDATE " . XDB::table($this->_table) . " SET level='0' WHERE %i", array(XDB::field('fid', $fids))); }
public function fix_update_block($hash, $data) { return XDB::update($this->_blockstyletable, $data, XDB::field('hash', $hash)); }