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


PHP Query::applyOptions方法代码示例

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


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

示例1: testGetOptions

 /**
  * Tests getOptions() method
  *
  * @return void
  */
 public function testGetOptions()
 {
     $options = ['doABarrelRoll' => true, 'fields' => ['id', 'name']];
     $query = new Query($this->connection, $this->table);
     $query->applyOptions($options);
     $expected = ['doABarrelRoll' => true];
     $this->assertEquals($expected, $query->getOptions());
     $expected = ['doABarrelRoll' => false, 'doAwesome' => true];
     $query->applyOptions($expected);
     $this->assertEquals($expected, $query->getOptions());
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:16,代码来源:QueryTest.php

示例2: findObfuscate

 /**
  * Custom finder that obfuscates primary keys in returned result set.
  *
  * @param \Cake\ORM\Query $query Query.
  * @param array $options Options.
  * @return \Cake\ORM\Query
  */
 public function findObfuscate(Query $query, array $options)
 {
     $query->applyOptions(['obfuscate' => true]);
     $query->formatResults(function ($results) {
         return $results->map(function ($row) {
             $pk = $this->_table->primaryKey();
             $row[$pk] = $this->obfuscate($row[$pk]);
             return $row;
         });
     });
     return $query;
 }
开发者ID:UseMuffin,项目名称:Obfuscate,代码行数:19,代码来源:ObfuscateBehavior.php

示例3: callFinder

 /**
  * Calls a finder method directly and applies it to the passed query,
  * if no query is passed a new one will be created and returned
  *
  * @param string $type name of the finder to be called
  * @param \Cake\ORM\Query $query The query object to apply the finder options to
  * @param array $options List of options to pass to the finder
  * @return \Cake\ORM\Query
  * @throws \BadMethodCallException
  */
 public function callFinder($type, Query $query, array $options = [])
 {
     $query->applyOptions($options);
     $options = $query->getOptions();
     $finder = 'find' . $type;
     if (method_exists($this, $finder)) {
         return $this->{$finder}($query, $options);
     }
     if ($this->_behaviors && $this->_behaviors->hasFinder($type)) {
         return $this->_behaviors->callFinder($type, [$query, $options]);
     }
     throw new \BadMethodCallException(sprintf('Unknown finder method "%s"', $type));
 }
开发者ID:yao-dev,项目名称:blog-mvc.github.io,代码行数:23,代码来源:Table.php

示例4: _filterByConditions

 /**
  * Method that filters ORM records by provided conditions.
  *
  * @param  \Cake\ORM\Query   $query Query object
  * @param  \Cake\Event\Event $event The event
  * @return void
  */
 protected function _filterByConditions(Query $query, Event $event)
 {
     if (empty($event->subject()->request->query('conditions'))) {
         return;
     }
     $conditions = [];
     $tableName = $event->subject()->name;
     foreach ($event->subject()->request->query('conditions') as $k => $v) {
         if (false === strpos($k, '.')) {
             $k = $tableName . '.' . $k;
         }
         $conditions[$k] = $v;
     }
     $query->applyOptions(['conditions' => $conditions]);
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:22,代码来源:IndexViewListener.php


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