本文整理汇总了PHP中Cake\ORM\Query::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::bind方法的具体用法?PHP Query::bind怎么用?PHP Query::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Query
的用法示例。
在下文中一共展示了Query::bind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
/**
* {@inheritdoc}
*/
public function apply($fromAlias, $fromIdentifier, $resourcePrefix, array $requesterIdentifiers, $mask, array $orX = [])
{
$this->query->join(['table' => $this->getAclSchema()->getPermissionsTableName(), 'alias' => 'acl_p', 'type' => 'LEFT', 'conditions' => $this->query->newExpr()->eq('acl_p.resource', $this->query->func()->concat([':acl_resource_prefix' => 'literal', $fromAlias . '.' . $fromIdentifier => 'literal']))]);
$orX[] = $this->query->newExpr()->and_([$this->query->newExpr()->in('acl_p.requester', $requesterIdentifiers, 'string'), $this->query->newExpr(':acl_mask = (acl_p.mask & :acl_mask)')]);
$this->query->andWhere($this->query->newExpr()->or_($orX));
$this->query->bind(':acl_resource_prefix', $resourcePrefix);
$this->query->bind(':acl_mask', $mask, 'integer');
return $this->query;
}
示例2: findMatches
/**
* Find Matches
*
* Assemble a query containing one or more MATCH() AGAINST() clauses
* @param \Cake\ORM\Query $query Query to modify
* @param array $options Options for the query
* @throws SearchableException If keys 'match' or 'against' are not set
* @throws SearchableException If columns are invalid
* @return \Cake\ORM\Query
*/
public function findMatches(Query $query, array $options)
{
$conditions = [];
$options = array_values($options);
//assemble MATCH() AGAINST() clauses
foreach ($options as $key => $option) {
if (!isset($option['match']) || !isset($option['against'])) {
throw new SearchableException("Keys 'match' and 'against' must be set");
}
if ($this->_validateColumns($option['match'])) {
$conditions[$key] = "MATCH({$option['match']}) AGAINST (:match{$key} ";
if (isset($option['mode'])) {
if (in_array($option['mode'], $this->_modesWhitelist)) {
$conditions[$key] .= $option['mode'] . ' ';
}
}
$conditions[$key] .= ")";
}
}
$query->find('all', ['conditions' => $conditions]);
//bind params
foreach ($options as $key => $option) {
$query->bind(":match{$key}", $option['against']);
}
return $query;
}