public function update_by_id_username($id, $data, $username, $adminid = 1) { if (($id = dintval($id, true)) && $data && is_array($data)) { $adminid = dintval($adminid); DB::update($this->_table, $data, DB::field($this->_pk, $id) . " AND ('{$adminid}'=1 OR " . DB::field('author', $username) . ')', true); } }
public function count_by_access($access) { if (!is_numeric($access) && !is_array($access)) { return 0; } return DB::result_first('SELECT COUNT(*) FROM %t WHERE ' . DB::field('access', $access), array($this->_table)); }
public function delete_by_touid($touids) { if (empty($touids)) { return false; } return DB::query('DELETE FROM mc, mq USING %t AS mc, %t AS mq WHERE mc.' . DB::field('touid', $touids) . ' AND mc.cid=mq.cid', array($this->_table, 'common_mailqueue'), false, true); }
public function delete_by_pid($pids) { if (empty($pids)) { return false; } return DB::query('DELETE FROM %t WHERE ' . DB::field('pid', $pids), array($this->_table), false, true); }
public function delete($id, $uid = 0) { if (empty($id)) { return false; } return DB::query('DELETE FROM %t WHERE ' . DB::field('id', $id) . ' %i', array($this->_table, $uid ? ' AND ' . DB::field('uid', $uid) : '')); }
public function delete_by_tid($tids) { if (!$tids) { return; } return DB::delete($this->_table, DB::field('tid', $tids)); }
public function delete_by_identifier($identifier) { if (!$identifier) { return; } DB::delete('common_plugin', DB::field('identifier', $identifier)); }
public function fetch_all_by_uid($uid, $new, $type, $start, $perpage) { $new = intval($new); $type = $type ? ' AND ' . DB::field('type', $type) : ''; $new = ' AND ' . DB::field('new', $new); return DB::fetch_all("SELECT * FROM %t WHERE uid=%d %i %i ORDER BY new DESC, dateline DESC %i", array($this->_table, $uid, $type, $new, DB::limit($start, $perpage))); }
public function fetch_all_by_name($name) { if (!empty($name)) { return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('name', $name), array($this->_table)); } return array(); }
public function fetch_all_by_doid($doids) { if (empty($doids)) { return array(); } return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('doid', $doids) . ' ORDER BY dateline', array($this->_table)); }
public function delete_by_dateline($dateline) { if (!is_numeric($dateline)) { return false; } return DB::delete($this->_table, DB::field('dateline', $dateline, '<=')); }
public function update_by_scriptname($scriptname, $data) { if (!$data || !is_array($data)) { return; } DB::update($this->_table, $data, DB::field('scriptname', $scriptname)); }
public function update_by_typeid($typeid, $data) { if (($typeid = dintval($typeid, true)) && !empty($data) && is_array($data)) { return DB::update($this->_table, $data, DB::field('typeid', $typeid)); } return false; }
public function delete($id) { if(!$id) { return "学院删除失败,id为空!"; } DB::delete($this->_table, DB::field('id', $id)); return "学院删除成功!"; }
public function update($ctid, $uid, $data, $unbuffered = false, $low_priority = false) { if (!empty($data) && is_array($data) && $ctid && $uid) { return DB::update($this->_table, $data, DB::field('ctid', $ctid) . ' AND ' . DB::field('uid', $uid), $unbuffered, $low_priority); } return !$unbuffered ? 0 : false; }
public function delete_by_fid($fid) { if (empty($fid)) { return false; } DB::query("DELETE FROM " . DB::table('forum_groupcreditslog') . " WHERE " . DB::field('fid', $fid)); }
public function delete_by_styleid($id, $stylevarids = array()) { if (!$id) { return; } DB::delete($this->_table, ($stylevarids ? DB::field('stylevarid', $stylevarids) . ' AND ' : '') . DB::field('styleid', $id)); }
public function delete_by_uid($uid) { if (!$uid) { return null; } return DB::delete($this->_table, DB::field('uid', $uid)); }
public function fetch_all_by_fid($fid, $position = false, $moderatorid = false, $start = 0, $limit = 0) { $position = $position ? ' AND ' . DB::field('position', array(0, $position)) : ''; $moderatorid = $moderatorid ? ' AND ' . DB::field('moderatorid', array(0, $moderatorid)) : ''; $limit = $start && $limit ? ' LIMIT ' . intval($start) . ', ' . intval($limit) : ''; return DB::fetch_all('SELECT * FROM %t WHERE fid=%d %i %i ORDER BY displayorder %i', array($this->_table, $fid, $position, $moderatorid, $limit)); }
public function fetch_all_by_search($aid, $authorid, $starttime, $endtime, $idtype, $message, $start = 0, $limit = 0, $type = 1) { $idtype = in_array($idtype, array('aid', 'topicid')) ? $idtype : 'aid'; $tablename = $idtype == 'aid' ? 'portal_article_title' : 'portal_topic'; $sql = ''; $sql .= $aid ? ' AND c.' . DB::field('id', $aid) : ''; $sql .= $authorid ? ' AND c.' . DB::field('uid', $authorid) : ''; $sql .= $starttime ? ' AND c.' . DB::field('dateline', $starttime, '>') : ''; $sql .= $endtime ? ' AND c.' . DB::field('dateline', $endtime, '<') : ''; if ($message != '') { $sqlmessage = ''; $or = ''; $message = daddslashes($message); $message = explode(',', str_replace(' ', '', $message)); for ($i = 0; $i < count($message); $i++) { if (preg_match("/\\{(\\d+)\\}/", $message[$i])) { $message[$i] = preg_replace("/\\\\{(\\d+)\\\\}/", ".{0,\\1}", preg_quote($message[$i], '/')); $sqlmessage .= " {$or} c.message REGEXP '" . $message[$i] . "'"; } else { $sqlmessage .= " {$or} c.message LIKE '%" . $message[$i] . "%'"; } $or = 'OR'; } if ($sqlmessage) { $sql .= " AND ({$sqlmessage})"; } } if ($type == 2) { return DB::result_first('SELECT count(*) FROM %t c WHERE 1 %i', array($this->_table, $sql)); } else { return DB::fetch_all('SELECT c.*, a.title FROM %t c LEFT JOIN %t a ON a.`' . $idtype . '`=c.id WHERE 1 %i ORDER BY c.dateline DESC %i', array($this->_table, $tablename, $sql, DB::limit($start, $limit))); } }
public function update_cpgroupid_by_cpgroupid($val, $data) { if (!is_array($data)) { return null; } return DB::update('common_admincp_member', $data, DB::field('cpgroupid', $val)); }
public function increase($tids, $fieldarr) { $tids = dintval((array) $tids, true); $sql = array(); $num = 0; $allowkey = array('replies', 'lastposter', 'lastpost'); foreach ($fieldarr as $key => $value) { if (in_array($key, $allowkey)) { if (is_array($value)) { $sql[] = DB::field($key, $value[0]); } else { $value = dintval($value); $sql[] = "`{$key}`=`{$key}`+'{$value}'"; } } else { unset($fieldarr[$key]); } } if ($getsetarr) { return $sql; } if (!empty($sql)) { $cmd = "UPDATE "; $num = DB::query($cmd . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE tid IN (" . dimplode($tids) . ")", 'UNBUFFERED'); $this->increase_cache($tids, $fieldarr); } return $num; }
public function delete_for_thread($tid, $applyids = array()) { if ($applyids) { $pksql = " AND " . DB::field('applyid', $applyids); } DB::query("DELETE FROM %t WHERE tid=%d {$pksql}", array($this->_table, $tid)); }
public function fetch_all($start = 0, $limit = 100, $operated = 0, $fid = 0) { $where = empty($operated) ? 'opuid=0' : 'opuid>0'; $order = empty($operated) ? 'num' : 'optime'; $fidsql = $fid ? ' AND ' . DB::field('fid', $fid) : ''; return DB::fetch_all("SELECT * FROM %t WHERE {$where}.{$fidsql} ORDER BY {$order} DESC, dateline DESC LIMIT %d, %d", array($this->_table, $start, $limit)); }
public function sum_amount_by_uid_submitdate_status($uid, $submitdate, $status) { if (empty($status)) { return 0; } return DB::result_first('SELECT SUM(amount) FROM %t WHERE uid=%d AND submitdate>=%d AND ' . DB::field('status', $status), array($this->_table, $uid, $submitdate)); }
public function fetch_all_for_order($typeid = array()) { if (!empty($typeid)) { $where = ' WHERE ' . DB::field('typeid', $typeid); } return DB::fetch_all("SELECT * FROM " . DB::table('forum_threadtype') . " {$where} ORDER BY displayorder"); }
public function update_by_threadtableid($threadtableid, $data, $unbuffered = false, $low_priority = false) { if (empty($data)) { return false; } return DB::update($this->_table, $data, DB::field('threadtableid', $threadtableid), $unbuffered, $low_priority); }
public function update_by_find($find, $data) { if (!empty($find) && !empty($data) && is_array($data)) { return DB::update($this->_table, $data, DB::field('find', $find)); } return 0; }
public function delete_by_variable($pluginid, $variable) { if (!$pluginid || !$variable) { return; } DB::delete($this->_table, DB::field('pluginid', $pluginid) . ' AND ' . DB::field('variable', $variable)); }
public function delete($val) { if (!$val) { return; } DB::query("DELETE FROM %t WHERE %i AND templateid<>1", array($this->_table, DB::field('templateid', $val))); }