本文整理汇总了PHP中XDB::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::limit方法的具体用法?PHP XDB::limit怎么用?PHP XDB::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::limit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_all_by_id_idtype
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);
}
示例2: fetch_all_for_manage
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));
}
示例3: fetch_all_for_ranklist
public function fetch_all_for_ranklist($status, $type, $orderfield, $start = 0, $limit = 0, $ignorefids = array())
{
if (empty($orderfield)) {
return array();
}
$typesql = $type ? ' AND f.' . XDB::field('type', $type) : ' AND f.type<>\'group\'';
$ignoresql = $ignorefids ? ' AND f.fid NOT IN(' . dimplode($ignorefids) . ')' : '';
if ($orderfield == 'membernum') {
$fields = ', ff.membernum';
$jointable = ' LEFT JOIN ' . XDB::table('forum_forumfield') . ' ff ON ff.fid=f.fid';
$orderfield = 'ff.' . $orderfield;
}
return XDB::fetch_all("SELECT f.* {$fields} FROM %t f {$jointable} WHERE f.status=%d {$typesql} {$ignoresql} ORDER BY %i DESC " . XDB::limit($start, $limit), array($this->_table, $status, $orderfield));
}
示例4: fetch_all_group_for_user
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));
}
示例5: range
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 : '');
}
示例6: fetch_all_by_search
public function fetch_all_by_search($fetchtype, $uids, $albumname, $searchname, $catid, $starttime, $endtime, $albumids, $friend = '', $orderfield = '', $ordersort = 'DESC', $start = 0, $limit = 0, $findex = '')
{
$parameter = array($this->_table);
$wherearr = array();
if (is_array($uids) && count($uids)) {
$parameter[] = $uids;
$wherearr[] = 'uid IN(%n)';
}
if ($albumname) {
if ($searchname == false) {
$parameter[] = $albumname;
$wherearr[] = 'albumname=%s';
} else {
$parameter[] = '%' . $albumname . '%';
$wherearr[] = 'albumname LIKE %s';
}
}
if ($catid) {
$parameter[] = $catid;
$wherearr[] = 'catid=%d';
}
if ($starttime) {
$parameter[] = is_numeric($starttime) ? $starttime : strtotime($starttime);
$wherearr[] = 'dateline>%d';
}
if ($endtime) {
$parameter[] = is_numeric($endtime) ? $endtime : strtotime($endtime);
$wherearr[] = 'dateline<%d';
}
if (is_numeric($friend)) {
$parameter[] = $friend;
$wherearr[] = 'friend=%d';
}
if (is_array($albumids) && count($albumids)) {
$parameter[] = $albumids;
$wherearr[] = 'albumid IN(%n)';
}
if ($fetchtype == 3) {
$selectfield = "count(*)";
} elseif ($fetchtype == 2) {
$selectfield = "albumid";
} else {
$selectfield = "*";
if (is_string($orderfield) && ($order = XDB::order($orderfield, $ordersort))) {
$ordersql = 'ORDER BY ' . $order;
}
if ($limit) {
$parameter[] = XDB::limit($start, $limit);
$ordersql .= ' %i';
}
}
if ($findex) {
$findex = 'USE INDEX(updatetime)';
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
if ($fetchtype == 3) {
return XDB::result_first("SELECT {$selectfield} FROM %t {$wheresql}", $parameter);
} else {
return XDB::fetch_all("SELECT {$selectfield} FROM %t {$findex} {$wheresql} {$ordersql}", $parameter);
}
}
示例7: fetch_all_by_special
public function fetch_all_by_special($special, $authorid = 0, $replies = 0, $displayorder = null, $subject = '', $join = 0, $start = 0, $limit = 0, $order = 'dateline', $sort = 'DESC')
{
$condition = $this->make_special_condition($special, $authorid, $replies, $displayorder, $subject, $join, 0);
$ordersql = !empty($order) ? ' ORDER BY t.' . XDB::order($order, $sort) : '';
return XDB::fetch_all("SELECT t.* FROM %t t {$condition['jointable']} " . $condition['where'] . $ordersql . XDB::limit($start, $limit), $condition['parameter'], $this->_pk);
}
示例8: fetch_all_recyclebin_by_dateline
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));
}
示例9: fetch_all_prune_by_search
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;
}
示例10: fetch_all_by_id
public function fetch_all_by_id($tableid, $idtype, $ids, $orderby = '', $isimage = false, $isprice = false, $remote = false, $limit = false)
{
if ($this->_check_id($idtype, $ids)) {
$attachments = array();
if ($orderby) {
$orderby = 'ORDER BY ' . $orderby;
}
$isimage = $isimage === false ? '' : ' AND ' . XDB::field('isimage', $isimage);
$isprice = $isprice === false ? '' : ' AND ' . XDB::field('price', 0, '>');
$remote = $remote === false ? '' : ' AND ' . XDB::field('remote', $remote);
$limit = $limit < 1 ? '' : XDB::limit(0, $limit);
$query = XDB::query("SELECT * FROM %t WHERE %i %i %i %i %i %i", array($this->_get_table($tableid), XDB::field($idtype, $ids), $isimage, $isprice, $remote, $orderby, $limit));
while ($value = XDB::fetch($query)) {
$attachments[$value['aid']] = $value;
}
return $attachments;
} else {
return array();
}
}