本文整理汇总了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;
}
示例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]);
});
}
示例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;
}
示例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;
}
示例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);
});
});
}
示例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]);
});
}
示例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]);
});
}
示例8: findWithAuthors
/**
* Authors search finder
*
* @param Query $query query object instance
* @return $this
*/
public function findWithAuthors(Query $query)
{
return $query->matching('Authors');
}
示例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']);
}
示例10: findByHashtag
public function findByHashtag(Query $query, array $options)
{
return $query->matching('Hashtags', function ($q) use($options) {
return $q->where(['Hashtags.name' => $options['hashtag']]);
});
}
示例11: findTagged
public function findTagged(Query $query, $options)
{
return $query->matching('Tags', function ($q) use($options) {
return $q->where(['Tags.title' => $options['tag']]);
});
}
示例12: findVencido
public function findVencido(Query $query, array $options)
{
return $query->matching('Anuncio', function ($q) {
return $q->find('vencido');
});
}