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


PHP Query::bind方法代碼示例

本文整理匯總了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;
 }
開發者ID:alexdpy,項目名稱:acl,代碼行數:12,代碼來源:CakephpOrmAclFilter.php

示例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;
 }
開發者ID:chris48s,項目名稱:cakephp-searchable,代碼行數:36,代碼來源:SearchableBehavior.php


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