当前位置: 首页>>代码示例>>PHP>>正文


PHP SelectQuery::order方法代码示例

本文整理汇总了PHP中SelectQuery::order方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::order方法的具体用法?PHP SelectQuery::order怎么用?PHP SelectQuery::order使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SelectQuery的用法示例。


在下文中一共展示了SelectQuery::order方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public static function get($hook, $type = 'pre')
 {
     if (!BACKEND_WITH_DATABASE) {
         return false;
     }
     $params = array(':type' => $type, ':hook' => $hook);
     $query = new SelectQuery('Hook');
     $query->leftJoin('Component', array('`hooks`.`class` = `components`.`name`'))->filter('`hooks`.`hook` = :hook')->filter('`hooks`.`type` = :type')->filter('`hooks`.`active` = 1')->filter('`components`.`active` = 1');
     if (Controller::$area) {
         $query->filter('`global` = 1 OR `class` = :area');
         $params[':area'] = Controller::$area;
     }
     if (Controller::$view && Controller::$view->mode) {
         $query->filter('`mode` IN (:mode, \'*\')');
         $params[':mode'] = Controller::$view->mode;
     }
     $query->order('`sequence`');
     return $query->fetchAll($params);
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:19,代码来源:Hook.obj.php

示例2: get

 public static function get($id, array $options = array())
 {
     $tag = Tag::retrieve($id, 'dbobject');
     if (!$tag || !$tag->array) {
         return false;
     }
     $links = self::getObject($tag->array['foreign_table']);
     list($query, $params) = $links->getSelectSQL();
     if (!$query instanceof SelectQuery) {
         return false;
     }
     $query_links = new SelectQuery('TagLink');
     $query_links->field('`foreign_id`')->filter('`tag_id` = :tag_id');
     if (array_key_exists('active', $links->getMeta('fields'))) {
         $query_links->filter('`active` = 1');
     }
     $order = $query_links->getOrder();
     if (empty($order) && array_key_exists('added', $links->getMeta('fields'))) {
         $query_links->order('`added` DESC');
     }
     $start = array_key_exists('start', $options) ? $options['start'] : 0;
     $count = array_key_exists('count', $options) ? $options['count'] : Value::get('list_length', 5);
     $query->field(':tag_id AS `tag_id`')->filter('`' . $links->getMeta('id_field') . '` IN (' . $query_links . ')')->limit("{$start}, {$count}");
     $params = array(':tag_id' => $tag->getMeta('id'));
     $links->load(array('mode' => 'list', 'query' => $query, 'parameters' => $params));
     $tag->array['list'] = $links->list;
     $tag->array['list_count'] = $links->list_count;
     return $tag;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:29,代码来源:Tag.obj.php

示例3: getSelectSQL

 public function getSelectSQL($options = array())
 {
     //Check the DB Connection
     $this->error_msg = false;
     if (!$this->checkConnection()) {
         if (class_exists('BackendError', false)) {
             BackendError::add(get_class($this) . ': DB Connection Error', 'getSelectSQL');
         }
         $this->error_msg = 'DB Connection Error';
         return false;
     }
     $mode = array_key_exists('mode', $options) ? $options['mode'] : 'list';
     $query = new SelectQuery($this, array('connection' => $this->db));
     //Fields
     $fields = array_key_exists('fields', $options) ? $options['fields'] : array();
     if (empty($fields)) {
         $query->field("`{$this->meta['table']}`.*");
     } else {
         $query->field($fields);
     }
     //Joins
     $joins = array_key_exists('joins', $options) ? $options['joins'] : array();
     if (count($joins)) {
         foreach ($joins as $join) {
             if (is_array($join)) {
                 $query->joinArray($join);
             }
         }
     }
     $q_params = array();
     if (!empty($options['conditions'])) {
         $query->filter($options['conditions']);
     }
     //Mode specific
     $limit = false;
     switch ($mode) {
         case 'object':
         case 'array':
         case 'full_object':
             if (!empty($this->meta['id'])) {
                 $query->filter("`{$this->meta['table']}`.`{$this->meta['id_field']}` = :{$this->meta['table']}_id");
                 $q_params[":{$this->meta['table']}_id"] = $this->meta['id'];
             } else {
                 $query->limit(empty($limit) ? 1 : $limit);
             }
             break;
         case 'list':
             if (array_key_exists('limit', $options) && $options['limit'] != 'all') {
                 $query->limit($options['limit']);
             }
             break;
     }
     //Parameters
     if (array_key_exists('parameters', $options)) {
         if (is_array($options['parameters'])) {
             $q_params = array_merge($q_params, $options['parameters']);
         } else {
             $q_params[] = $options['parameters'];
         }
     } else {
         if (!empty($this->meta['parameters'])) {
             if (is_array($this->meta['parameters'])) {
                 $q_params = array_merge($q_params, $this->meta['parameters']);
             } else {
                 $q_params[] = $parameters;
             }
         }
     }
     //Filters
     if (array_key_exists('filters', $options)) {
         $query->filter($options['filters']);
     } else {
         if (!empty($this->meta['filters'])) {
             $query->filter($this->meta['filters']);
         }
     }
     //Order
     if (array_key_exists('order', $options)) {
         $query->order($options['order']);
     } else {
         if (!empty($this->meta['order'])) {
             $query->order($this->meta['order']);
         }
     }
     //Group
     if (array_key_exists('group', $options)) {
         $query->group($options['group']);
     } else {
         if (!empty($this->meta['group'])) {
             $query->group($this->meta['group']);
         }
     }
     //Check Ownership
     if (array_key_exists('owner_id', $this->meta['fields'])) {
         if ($user = BackendUser::check()) {
             if (!in_array('superadmin', $user->roles)) {
                 $query->filter("`{$this->meta['table']}`.`owner_id` = :owner_id");
                 $q_params[':owner_id'] = $user->id;
             }
         }
//.........这里部分代码省略.........
开发者ID:jrgns,项目名称:backend-php,代码行数:101,代码来源:DBObject.obj.php


注:本文中的SelectQuery::order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。