當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。