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


PHP Query::aliasFields方法代码示例

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


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

示例1: _buildSubquery

 /**
  * Builds a query to be used as a condition for filtering records in the
  * target table, it is constructed by cloning the original query that was used
  * to load records in the source table.
  *
  * @param \Cake\ORM\Query $query the original query used to load source records
  * @return \Cake\ORM\Query
  */
 protected function _buildSubquery($query)
 {
     $filterQuery = clone $query;
     $filterQuery->autoFields(false);
     $filterQuery->mapReduce(null, null, true);
     $filterQuery->formatResults(null, true);
     $filterQuery->contain([], true);
     if (!$filterQuery->clause('limit')) {
         $filterQuery->limit(null);
         $filterQuery->order([], true);
         $filterQuery->offset(null);
     }
     $keys = (array) $this->bindingKey();
     if ($this->type() === $this::MANY_TO_ONE) {
         $keys = (array) $this->foreignKey();
     }
     $fields = $query->aliasFields($keys, $this->source()->alias());
     $filterQuery->select($fields, true)->group(array_values($fields));
     return $filterQuery;
 }
开发者ID:wepbunny,项目名称:cake2,代码行数:28,代码来源:SelectableAssociationTrait.php

示例2: _appendFields

 /**
  * Helper function used to conditionally append fields to the select clause of
  * a query from the fields found in another query object.
  *
  * @param \Cake\ORM\Query $query the query that will get the fields appended to
  * @param \Cake\ORM\Query $surrogate the query having the fields to be copied from
  * @param array $options options passed to the method `attachTo`
  * @return void
  */
 protected function _appendFields($query, $surrogate, $options)
 {
     $fields = $surrogate->clause('select') ?: $options['fields'];
     $target = $this->_targetTable;
     $autoFields = $surrogate->autoFields();
     if ($query->eagerLoader()->autoFields() === false) {
         return;
     }
     if (empty($fields) && !$autoFields) {
         if ($options['includeFields'] && ($fields === null || $fields !== false)) {
             $fields = $target->schema()->columns();
         }
     }
     if ($autoFields === true) {
         $fields = array_merge((array) $fields, $target->schema()->columns());
     }
     if (!empty($fields)) {
         $query->select($query->aliasFields($fields, $target->alias()));
     }
 }
开发者ID:m1nd53t,项目名称:cakephp,代码行数:29,代码来源:Association.php

示例3: _buildSubquery

 /**
  * Builds a query to be used as a condition for filtering records in the
  * target table, it is constructed by cloning the original query that was used
  * to load records in the source table.
  *
  * @param \Cake\ORM\Query $query the original query used to load source records
  * @return \Cake\ORM\Query
  */
 protected function _buildSubquery($query)
 {
     $filterQuery = clone $query;
     $filterQuery->limit(null);
     $filterQuery->order([], true);
     $filterQuery->contain([], true);
     $joins = $filterQuery->join();
     foreach ($joins as $i => $join) {
         if (strtolower($join['type']) !== 'inner') {
             unset($joins[$i]);
         }
     }
     $keys = (array) $query->repository()->primaryKey();
     if ($this->type() === $this::MANY_TO_ONE) {
         $keys = (array) $this->foreignKey();
     }
     $filterQuery->join($joins, [], true);
     $fields = $query->aliasFields($keys);
     return $filterQuery->select($fields, true);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:28,代码来源:SelectableAssociationTrait.php

示例4: _subqueryFields

 /**
  * Calculate the fields that need to participate in a subquery.
  *
  * Normally this includes the binding key columns. If there is a an ORDER BY,
  * those columns are also included as the fields may be calculated or constant values,
  * that need to be present to ensure the correct association data is loaded.
  *
  * @param \Cake\ORM\Query $query The query to get fields from.
  * @return array The list of fields for the subquery.
  */
 protected function _subqueryFields($query)
 {
     $keys = (array) $this->bindingKey();
     if ($this->type() === $this::MANY_TO_ONE) {
         $keys = (array) $this->foreignKey();
     }
     $fields = $query->aliasFields($keys, $this->source()->alias());
     $group = $fields = array_values($fields);
     $order = $query->clause('order');
     if ($order) {
         $columns = $query->clause('select');
         $order->iterateParts(function ($direction, $field) use(&$fields, $columns) {
             if (isset($columns[$field])) {
                 $fields[$field] = $columns[$field];
             }
         });
     }
     return ['select' => $fields, 'group' => $group];
 }
开发者ID:CakeDC,项目名称:cakephp,代码行数:29,代码来源:SelectableAssociationTrait.php

示例5: _appendFields

 /**
  * Helper function used to conditionally append fields to the select clause of
  * a query from the fields found in another query object.
  *
  * @param \Cake\ORM\Query $query the query that will get the fields appended to
  * @param \Cake\ORM\Query $surrogate the query having the fields to be copied from
  * @param array $options options passed to the method `attachTo`
  * @return void
  */
 protected function _appendFields($query, $surrogate, $options)
 {
     $options['fields'] = $surrogate->clause('select') ?: $options['fields'];
     $target = $this->_targetTable;
     if (empty($options['fields'])) {
         $f = isset($options['fields']) ? $options['fields'] : null;
         if ($options['includeFields'] && ($f === null || $f !== false)) {
             $options['fields'] = $target->schema()->columns();
         }
     }
     if (!empty($options['fields'])) {
         $query->select($query->aliasFields($options['fields'], $target->alias()));
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:23,代码来源:Association.php


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