本文整理汇总了PHP中DB::order方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::order方法的具体用法?PHP DB::order怎么用?PHP DB::order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::order方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_all_by_id_idtype
public function fetch_all_by_id_idtype($id, $idtype, $start, $limit, $cid = '', $order = '')
{
if ($cid) {
$cidsql = DB::field('cid', $cid) . ' AND ';
}
return DB::fetch_all('SELECT * FROM %t WHERE ' . $cidsql . ' id=%d AND idtype=%s ORDER BY ' . DB::order('dateline', $order) . ' %i', array($this->_table, $id, $idtype, DB::limit($start, $limit)));
}
示例2: fetch_all
public function fetch_all($ctid = '', $orderby = '', $ordersc = '', $start = 0, $limit = 0, $title = '', $cachetid = '')
{
if ($this->_allowmem && $cachetid) {
$data = $this->fetch_cache($cachetid, $this->_pre_cache_key . 'tid_');
if ($data) {
return $data;
}
}
$sql = '';
if ($ctid) {
$sql .= 'WHERE ' . DB::field('ctid', $ctid);
}
if ($title && str_replace('%', '', $title)) {
$sql .= ($sql ? ' AND ' : 'WHERE ') . DB::field('name', '%' . $title . '%', 'like');
}
$sql .= ($orderby = DB::order($orderby, $ordersc)) ? ' ORDER BY ' . $orderby : '';
$sql .= ' ' . DB::limit($start, $limit);
if (!$sql) {
return null;
}
$data = DB::fetch_all('SELECT * FROM %t %i', array($this->_table, $sql), $this->_pk);
if ($this->_allowmem && $cachetid) {
$this->store_cache($cachetid, $data, $this->_cache_ttl, $this->_pre_cache_key . 'tid_');
}
return $data;
}
示例3: setData
/**
* set data
*/
public function setData()
{
$obj = Factory::createObject('News');
$table = DB::table($obj->getTable());
$limit = new base_database_Limit(10);
$order = DB::order($table->getColumn('firstEditTime'));
$finder = Finder::create('news')->setOrder($order)->setlimit($limit);
$this->data = $finder->find();
}
示例4: fetch_all_by_upid
public function fetch_all_by_upid($upid, $order = null, $sort = 'DESC')
{
$upid = is_array($upid) ? array_map('intval', (array) $upid) : dintval($upid);
if ($upid !== null) {
$ordersql = $order !== null && !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : '';
return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('upid', $upid) . " {$ordersql}", array($this->_table), $this->_pk);
}
return array();
}
示例5: fetch_goods
public function fetch_goods($tid, $pid, $orderby = '', $ascdesc = 'asc', $start = 0, $limit = 0)
{
if (empty($pid)) {
return array();
}
if ($tid) {
$tidsql = DB::field('tid', $tid) . ' AND ';
}
if ($orderby) {
$ordersql = " ORDER BY " . DB::order($orderby, $ascdesc);
}
return DB::fetch_first("SELECT * FROM %t WHERE {$tidsql} " . DB::field('pid', $pid) . $ordersql . DB::limit($start, $limit), array($this->_table));
}
示例6: loadNaviStructure
public function loadNaviStructure()
{
$table = DB::table(Factory::createObject('navigationCategory')->getTable());
$order = DB::order($table->getColumn('sort'), base_database_Order::ASC);
$columnList = [$table->getColumn('name'), $table->getColumn('LK')];
$cats = Finder::create('navigationCategory')->setOrder($order)->find($columnList);
foreach ($cats as $catRow) {
$entriesForCategory = $this->loadEntriesForCategory($catRow['LK']);
if (!empty($entriesForCategory)) {
$this->naviStructure[$catRow['name']] = $entriesForCategory;
$this->catLKName[$catRow['name']] = $catRow['LK'];
}
}
}
示例7: fetch_all
public function fetch_all($ctid, $order = false, $start = 0, $limit = 0)
{
if (!$ctid) {
return null;
}
$sql = DB::field('ctid', $ctid);
if ($order) {
$sql .= ' ORDER BY ' . DB::order('dateline', 'DESC');
}
if ($limit) {
$sql .= DB::limit($start, $limit);
}
return DB::fetch_all('SELECT * FROM %t WHERE ' . $sql, array($this->_table));
}
示例8: fetch_all_by_available_icon
public function fetch_all_by_available_icon($available = null, $haveicon = false, $glue = '=', $order = 'displayorder', $sort = 'ASC')
{
$parameter = array($this->_table);
if ($available !== null) {
$parameter[] = $available;
$glue = helper_util::check_glue($glue);
$wherearr[] = "available{$glue}%d";
}
if ($haveicon) {
$wherearr[] = "icon!=''";
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
$ordersql = !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : '';
return DB::fetch_all("SELECT * FROM %t {$wheresql} {$ordersql}", $parameter, $this->_pk);
}
示例9: fetch_all_by_id
public function fetch_all_by_id($idtype, $ids, $orderby = '')
{
$attachments = array();
if ($orderby) {
$orderby = 'ORDER BY ' . DB::order($orderby, 'DESC');
}
if (in_array($idtype, array('aid', 'tid', 'pid', 'uid')) && $ids) {
$query = DB::query("SELECT * FROM %t WHERE %i IN (%n) %i", array($this->_table, $idtype, (array) $ids, $orderby));
while ($value = DB::fetch($query)) {
$attachments[$value['aid']] = $value;
$this->_tableids[$value['tableid']][] = $value['aid'];
}
}
return $attachments;
}
示例10: fetch_all_by_status
public function fetch_all_by_status($status = NUll, $tagname = '', $startlimit = 0, $count = 0, $returncount = 0, $order = '')
{
if ($status === NULL) {
$statussql = 'status<>3';
} else {
$statussql = 'status=' . intval($status);
}
$data = array($this->_table);
if ($tagname) {
$namesql = " AND tagname LIKE %s";
$data[] = '%' . $tagname . '%';
}
if ($returncount) {
return DB::result_first("SELECT count(*) FROM %t WHERE {$statussql} {$namesql}", $data);
}
return DB::fetch_all("SELECT * FROM %t WHERE {$statussql} {$namesql} ORDER BY " . DB::order('tagid', $order) . " " . DB::limit($startlimit, $count), $data);
}
示例11: fetch_all_by_id_idtype
public function fetch_all_by_id_idtype($id, $idtype = '', $orderby = '', $ordersc = 'DESC', $start = 0, $limit = 0)
{
if (!$id) {
return null;
}
$sql = array(DB::field('id', $id));
if ($idtype) {
$sql[] = DB::field('idtype', $idtype);
}
$wheresql = implode(' AND ', $sql);
if ($orderby = DB::order($orderby, $ordersc)) {
$wheresql .= ' ORDER BY ' . $orderby;
}
if ($limit) {
$wheresql .= DB::limit($start, $limit);
}
return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, $wheresql));
}
示例12: fetch_by_fid_dateline
public function fetch_by_fid_dateline($fid, $dateline = 0, $order = 'dateline', $sort = 'DESC')
{
$parameter = array($this->_table);
$wherearr = array();
$wheresql = '';
if ($fid) {
$wherearr[] = 'fid=%d';
$parameter[] = $fid;
}
if ($dateline) {
$wherearr[] = 'dateline=%d';
$parameter[] = $dateline;
}
if ($wherearr) {
$wheresql = ' WHERE ' . implode(' AND ', $wherearr);
}
return DB::fetch_first('SELECT * FROM %t ' . $wheresql . ' ORDER BY ' . DB::order($order, $sort), $parameter, $this->_pk);
}
示例13: select
public function select($tagid = 0, $itemid = 0, $idtype = '', $orderfield = '', $ordertype = 'DESC', $limit = 0, $count = 0, $itemidglue = '=', $returnnum = 0)
{
$data = self::make_where($tagid, $itemid, $idtype, $itemidglue);
$ordersql = $limitsql = '';
if ($orderfield) {
$ordersql = ' ORDER BY ' . DB::order($orderfield, $ordertype);
}
if ($limit) {
$limitsql = DB::limit($limit, $count);
}
if ($data) {
if ($returnnum) {
return DB::result_first('SELECT count(*) FROM %t WHERE ' . $data['where'], $data['data']);
}
return DB::fetch_all('SELECT * FROM %t WHERE ' . $data['where'] . $ordersql . $limitsql, $data['data']);
} else {
return false;
}
}
示例14: fetch_all_by_uid_appid
public function fetch_all_by_uid_appid($uid = 0, $appid = 0, $order = null, $sort = 'DESC', $start = 0, $limit = 0)
{
$parameter = array($this->_table);
$wherearr = array();
if ($uid) {
$uid = dintval((array) $uid, true);
$wherearr[] = 'uid IN(%n)';
$parameter[] = $uid;
}
if ($appid) {
$appid = dintval((array) $appid, true);
$wherearr[] = 'appid IN(%n)';
$parameter[] = $appid;
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
$sort = in_array($sort, array('DESC', 'ASC')) ? $sort : 'DESC';
$ordersql = $order !== null ? ' ORDER BY ' . DB::order($order, $sort) : '';
if (!$uid) {
$limit = $limit ? $limit : 100;
}
return DB::fetch_all("SELECT * FROM %t {$wheresql} {$ordersql} " . DB::limit($start, $limit), $parameter);
}
示例15: fetch_all_by_uid_doid
public function fetch_all_by_uid_doid($uids, $bannedids = '', $paramorderby = '', $startrow = 0, $items = 0, $status = true, $allfileds = false)
{
$parameter = array($this->_table);
$orderby = $paramorderby && in_array($paramorderby, array('dateline', 'replynum')) ? 'ORDER BY ' . DB::order($paramorderby, 'DESC') : 'ORDER BY ' . DB::order('dateline', 'DESC');
$wheres = array();
if ($uids) {
$parameter[] = $uids;
$wheres[] = 'uid IN (%n)';
}
if ($bannedids) {
$parameter[] = $bannedids;
$wheres[] = 'doid NOT IN (%n)';
}
if ($status) {
$wheres[] = ' status = 0';
}
$wheresql = !empty($wheres) && is_array($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : '';
if (empty($wheresql)) {
return null;
}
return DB::fetch_all('SELECT ' . ($allfileds ? '*' : 'doid') . ' FROM %t ' . $wheresql . ' ' . $orderby . DB::limit($startrow, $items), $parameter);
}