當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Query::matching方法代碼示例

本文整理匯總了PHP中Cake\ORM\Query::matching方法的典型用法代碼示例。如果您正苦於以下問題:PHP Query::matching方法的具體用法?PHP Query::matching怎麽用?PHP Query::matching使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\ORM\Query的用法示例。


在下文中一共展示了Query::matching方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findWithCount

 public function findWithCount(Query $query, array $options)
 {
     $query->select(['count' => $query->func()->count('Users.id')]);
     $query->matching('Users');
     $query->group(['UserRoles.id']);
     return $query;
 }
開發者ID:JulienPapini,項目名稱:CakeUser,代碼行數:7,代碼來源:UserRolesTable.php

示例2: findWithCitiesBiggerThanDenmark

 public function findWithCitiesBiggerThanDenmark(Query $query)
 {
     $denmarkPopulation = $this->find()->select(['population'])->where(['id' => 'DNK']);
     return $query->matching('Cities', function ($q) use($denmarkPopulation) {
         return $q->where(['Cities.population >' => $denmarkPopulation]);
     });
 }
開發者ID:harikt,項目名稱:cakephp3-examples,代碼行數:7,代碼來源:CountriesTable.php

示例3: findActive

 /**
  * "Active" find method
  * @param Query $query Query object
  * @param array $options Options
  * @return Query Query object
  */
 public function findActive(Query $query, array $options)
 {
     $query->where([sprintf('%s.active', $this->alias()) => true]);
     $query->matching('Albums', function ($q) {
         return $q->where([sprintf('%s.active', $this->Albums->alias()) => true]);
     });
     return $query;
 }
開發者ID:mirko-pagliai,項目名稱:me-cms,代碼行數:14,代碼來源:PhotosTable.php

示例4: findTagged

 public function findTagged(Query $query, array $options)
 {
     $query->contain(['Users', 'Users.AccountParameters', 'Hashtags']);
     $query->matching('Hashtags', function ($q) use($options) {
         return $q->where(['Hashtags.name' => $options['tag_name']]);
     });
     $query->order(['Tweets.created' => 'DESC']);
     return $query;
 }
開發者ID:TituxMetal,項目名稱:Twitthome-CakePHP3,代碼行數:9,代碼來源:TweetsTable.php

示例5: findCityProbability

 public function findCityProbability(Query $query)
 {
     return $query->matching('Countries.Cities', function ($q) {
         $prob = $q->newExpr('(Languages.percentage / 100) * (Cities.population / Countries.population)');
         return $q->select(['probability' => $prob, 'Cities.name'])->where(function ($exp) use($prob) {
             return $exp->gte($prob, 0.25);
         });
     });
 }
開發者ID:harikt,項目名稱:cakephp3-examples,代碼行數:9,代碼來源:LanguagesTable.php

示例6: findParticipating

 /**
  * Dynamic finder that find threads where given users are involved
  *
  * @param \Cake\ORM\Query $query the original query to append to
  * @param array $users the list of user ids like ```[1, 2, 3]```
  * @return \Cake\ORM\Query The amended query
  */
 public function findParticipating(Query $query, array $users = null)
 {
     if (empty($users)) {
         return $query;
     }
     return $query->matching('Users', function ($q) use($users) {
         return $q->where(['Users.id IN' => $users]);
     });
 }
開發者ID:gintonicweb,項目名稱:messages,代碼行數:16,代碼來源:ThreadsTable.php

示例7: scope

 /**
  * {@inheritDoc}
  */
 public function scope(Query $query, TokenInterface $token)
 {
     $value = $token->value();
     if (empty($value)) {
         return $query;
     }
     return $query->matching('Tags', function ($q) use($value) {
         $value = explode(',', $value);
         $names = array_map('trim', (array) $value);
         return $q->where(['Tags.name IN' => empty($names) ? ['---'] : $names]);
     });
 }
開發者ID:ChristopherCastro,項目名稱:gencon,代碼行數:15,代碼來源:TagOperator.php

示例8: findWithAuthors

 /**
  * Authors search finder
  *
  * @param  Query $query query object instance
  * @return $this
  */
 public function findWithAuthors(Query $query)
 {
     return $query->matching('Authors');
 }
開發者ID:kajko1973,項目名稱:plum_search,代碼行數:10,代碼來源:ArticlesTable.php

示例9: findForMembers

 public function findForMembers(Query $query, array $options)
 {
     return $query->matching('Users.Memberships', function ($q) {
         return $q->where(['Memberships.expires >=' => date('Y-m-d H:i:s')])->where([function ($exp, $q) {
             return $exp->isNull('canceled');
         }]);
     })->distinct(['Tags.id']);
 }
開發者ID:PhantomWatson,項目名稱:macc,代碼行數:8,代碼來源:TagsTable.php

示例10: findByHashtag

 public function findByHashtag(Query $query, array $options)
 {
     return $query->matching('Hashtags', function ($q) use($options) {
         return $q->where(['Hashtags.name' => $options['hashtag']]);
     });
 }
開發者ID:AFPA-Dijon,項目名稱:afpa,代碼行數:6,代碼來源:TweetsTable.php

示例11: findTagged

 public function findTagged(Query $query, $options)
 {
     return $query->matching('Tags', function ($q) use($options) {
         return $q->where(['Tags.title' => $options['tag']]);
     });
 }
開發者ID:nhan712,項目名稱:cakephp3-bookmarkr,代碼行數:6,代碼來源:BookmarksTable.php

示例12: findVencido

 public function findVencido(Query $query, array $options)
 {
     return $query->matching('Anuncio', function ($q) {
         return $q->find('vencido');
     });
 }
開發者ID:richellyitalo,項目名稱:estudoscakephp,代碼行數:6,代碼來源:PropertiesTable.php


注:本文中的Cake\ORM\Query::matching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。