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


PHP Query::eagerLoader方法代码示例

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


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

示例1: getProperty

 /**
  * Get CakePHP property
  *
  * @param string $dataName Column data name
  *
  * @throws Exception
  * @return array|string
  */
 protected function getProperty($dataName)
 {
     $dataName = explode('.', trim($dataName));
     if (count($dataName) != 2) {
         throw new Exception('You are set invalid date.');
     }
     $tableAlias = $dataName[0];
     $colName = $dataName[1];
     if ($this->query->repository()->alias() == $tableAlias) {
         return $colName;
     } elseif (array_key_exists($tableAlias, $this->query->contain())) {
         return ['propertyPath' => $this->query->eagerLoader()->normalized($this->query->repository())[$tableAlias]['propertyPath'], 'field' => $colName];
     }
 }
开发者ID:atkrad,项目名称:data-tables,代码行数:22,代码来源:CakePHP.php

示例2: _calculateAssociationMap

 /**
  * Calculates the list of associations that should get eager loaded
  * when fetching each record
  *
  * @return void
  */
 protected function _calculateAssociationMap()
 {
     $contain = $this->_query->eagerLoader()->normalized($this->_defaultTable);
     if (!$contain) {
         return;
     }
     $map = [];
     $visitor = function ($level) use(&$visitor, &$map) {
         foreach ($level as $assoc => $meta) {
             $map[$meta['aliasPath']] = ['alias' => $assoc, 'instance' => $meta['instance'], 'canBeJoined' => $meta['canBeJoined'], 'entityClass' => $meta['instance']->target()->entityClass(), 'nestKey' => $meta['canBeJoined'] ? $assoc : $meta['aliasPath']];
             if ($meta['canBeJoined'] && !empty($meta['associations'])) {
                 $visitor($meta['associations']);
             }
         }
     };
     $visitor($contain, []);
     $this->_associationMap = $map;
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:24,代码来源:ResultSet.php

示例3: _appendJunctionJoin

 /**
  * Append a join to the junction table.
  *
  * @param \Cake\ORM\Query $query The query to append.
  * @param string|array $conditions The query conditions to use.
  * @return \Cake\ORM\Query The modified query.
  */
 protected function _appendJunctionJoin($query, $conditions)
 {
     $name = $this->_junctionAssociationName();
     $joins = $query->join();
     $matching = [$name => ['table' => $this->junction()->table(), 'conditions' => $conditions, 'type' => 'INNER']];
     $assoc = $this->target()->association($name);
     $query->addDefaultTypes($assoc->target())->join($matching + $joins, [], true);
     $query->eagerLoader()->addToJoinsMap($name, $assoc);
     return $query;
 }
开发者ID:Mingyangzu,项目名称:PHP-cakephp,代码行数:17,代码来源:BelongsToMany.php

示例4: _bindNewAssociations

 /**
  * Applies all attachable associations to `$query` out of the containments found
  * in the `$surrogate` query.
  *
  * Copies all contained associations from the `$surrogate` query into the
  * passed `$query`. Containments are altered so that they respect the associations
  * chain from which they originated.
  *
  * @param \Cake\ORM\Query $query the query that will get the associations attached to
  * @param \Cake\ORM\Query $surrogate the query having the containments to be attached
  * @param array $options options passed to the method `attachTo`
  * @return void
  */
 protected function _bindNewAssociations($query, $surrogate, $options)
 {
     $loader = $surrogate->eagerLoader();
     $contain = $loader->contain();
     $matching = $loader->matching();
     if (!$contain && !$matching) {
         return;
     }
     $newContain = [];
     foreach ($contain as $alias => $value) {
         $newContain[$options['aliasPath'] . '.' . $alias] = $value;
     }
     $eagerLoader = $query->eagerLoader();
     $eagerLoader->contain($newContain);
     foreach ($matching as $alias => $value) {
         $eagerLoader->matching($options['aliasPath'] . '.' . $alias, $value['queryBuilder'], $value);
     }
 }
开发者ID:m1nd53t,项目名称:cakephp,代码行数:31,代码来源:Association.php

示例5: _calculateAssociationMap

 /**
  * Calculates the list of associations that should get eager loaded
  * when fetching each record
  *
  * @return void
  */
 protected function _calculateAssociationMap()
 {
     $map = $this->_query->eagerLoader()->associationsMap($this->_defaultTable);
     $this->_matchingMap = (new Collection($map))->match(['matching' => true])->indexBy('alias')->toArray();
     $this->_containMap = (new Collection(array_reverse($map)))->match(['matching' => false])->indexBy('nestKey')->toArray();
 }
开发者ID:QueenCityCodeFactory,项目名称:cakephp,代码行数:12,代码来源:ResultSet.php

示例6: _bindNewAssociations

 /**
  * Applies all attachable associations to `$query` out of the containments found
  * in the `$surrogate` query.
  *
  * Copies all contained associations from the `$surrogate` query into the
  * passed `$query`. Containments are altered so that they respect the associations
  * chain from which they originated.
  *
  * @param \Cake\ORM\Query $query the query that will get the associations attached to
  * @param \Cake\ORM\Query $surrogate the query having the containments to be attached
  * @param array $options options passed to the method `attachTo`
  * @return void
  */
 protected function _bindNewAssociations($query, $surrogate, $options)
 {
     $loader = $surrogate->eagerLoader();
     $contain = $loader->contain();
     $matching = $loader->matching();
     $target = $this->_targetTable;
     if (!$contain && !$matching) {
         return;
     }
     $loader->attachAssociations($query, $target, $options['includeFields']);
     $newContain = [];
     foreach ($contain as $alias => $value) {
         $newContain[$options['aliasPath'] . '.' . $alias] = $value;
     }
     $query->contain($newContain);
     foreach ($matching as $alias => $value) {
         $query->matching($options['aliasPath'] . '.' . $alias, $value['queryBuilder']);
     }
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:32,代码来源:Association.php

示例7: _bindNewAssociations

 /**
  * Applies all attachable associations to `$query` out of the containments found
  * in the `$surrogate` query.
  *
  * Copies all contained associations from the `$surrogate` query into the
  * passed `$query`. Containments are altered so that they respect the associations
  * chain from which they originated.
  *
  * @param \Cake\ORM\Query $query the query that will get the associations attached to
  * @param \Cake\ORM\Query $surrogate the query having the containments to be attached
  * @param array $options options passed to the method `attachTo`
  * @return void
  */
 protected function _bindNewAssociations($query, $surrogate, $options)
 {
     $contain = $surrogate->contain();
     $target = $this->_targetTable;
     if (!$contain) {
         return;
     }
     $loader = $surrogate->eagerLoader();
     $loader->attachAssociations($query, $target, $options['includeFields']);
     $newBinds = [];
     foreach ($contain as $alias => $value) {
         $newBinds[$options['aliasPath'] . '.' . $alias] = $value;
     }
     $query->contain($newBinds);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:28,代码来源:Association.php


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