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


PHP QueryBuilder::setParameter方法代码示例

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


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

示例1: fetch

 /**
  * @return array
  */
 public function fetch()
 {
     $data = $this->query->execute()->fetchAll(\PDO::FETCH_KEY_PAIR);
     $keys = array_keys($data);
     $this->query->setParameter(':lastId', array_pop($keys));
     return array_values($data);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:10,代码来源:LastIdQuery.php

示例2: apply

 /**
  * {@inheritdoc}
  */
 public function apply($fromAlias, $fromIdentifier, $resourcePrefix, array $requesterIdentifiers, $mask, array $orX = [])
 {
     $this->queryBuilder->leftJoin($fromAlias, $this->getAclSchema()->getPermissionsTableName(), 'acl_p', 'acl_p.resource = ' . $this->connection->getDatabasePlatform()->getConcatExpression(':acl_prefix', $fromAlias . '.' . $fromIdentifier));
     $orX[] = 'acl_p.requester IN (:acl_identifiers) AND :acl_mask = (acl_p.mask & :acl_mask)';
     $this->queryBuilder->andWhere(implode(' OR ', $orX));
     $this->queryBuilder->setParameter('acl_prefix', $resourcePrefix, \PDO::PARAM_STR)->setParameter('acl_identifiers', $requesterIdentifiers, Connection::PARAM_STR_ARRAY)->setParameter('acl_mask', $mask, \PDO::PARAM_INT);
     return $this->queryBuilder;
 }
开发者ID:alexdpy,项目名称:acl,代码行数:11,代码来源:DoctrineDbalAclFilter.php

示例3: setParameter

 /**
  * paramTypes is private, we need to redefine setParameter
  * to access it
  *
  * @param string $key
  * @param string $value
  * @param string $type
  *
  * @return $this
  */
 public function setParameter($key, $value, $type = null)
 {
     if ($type !== null) {
         $this->paramTypes[$key] = $type;
     }
     return parent::setParameter($key, $value, $type);
 }
开发者ID:Volyz,项目名称:barometre,代码行数:17,代码来源:QueryBuilder.php

示例4: match

 public function match(QueryBuilder $qb)
 {
     if ($this->has('username')) {
         $qb->andWhere('u.username = :username');
         $qb->setParameter('username', $this->get('username'));
     }
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:7,代码来源:FilterByUsernameSpecification.php

示例5: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     if (!$this->includeAllGroups) {
         $query->andWhere('g.gID > :minGroupID');
         $query->setParameter('minGroupID', REGISTERED_GROUP_ID);
     }
     return $query;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:8,代码来源:GroupList.php

示例6: process

 /**
  * Applies operation to data source and returns modified data source.
  *
  * @param QueryBuilder $src
  * @param OperationInterface|FilterOperation $operation
  * @return QueryBuilder
  */
 public function process($src, OperationInterface $operation)
 {
     $value = $operation->getValue();
     $operator = $operation->getOperator();
     $fieldName = $operation->getField();
     $parameterName = 'p' . md5($fieldName . $operator);
     $src->andWhere("{$fieldName} {$operator} :{$parameterName}");
     $src->setParameter($parameterName, $value);
     return $src;
 }
开发者ID:view-components,项目名称:doctrine-data-processing,代码行数:17,代码来源:FilterProcessor.php

示例7: match

    /**
     * @see \ComPHPPuebla\Doctrine\TableGateway\Specification\QueryBuilderSpecification::match()
     */
    public function match(QueryBuilder $qb)
    {
        if ($this->has('latitude') && $this->has('longitude')) {
            $qb->addSelect(<<<SELECT
    (6371
    * (2 * ATAN(SQRT(SIN(((:latitude - s.latitude) * (PI()/180))/2) * SIN(((:latitude - s.latitude) * (PI()/180))/2)
    + COS(:latitude * (PI()/180)) * COS(s.latitude * (PI()/180))
    * SIN(((:longitude - s.longitude) * (PI()/180))/2) * SIN(((:longitude - s.longitude) * (PI()/180))/2)),
            SQRT(1-(sin(((:latitude - s.latitude) * (PI()/180))/2) * SIN(((:latitude - s.latitude) * (PI()/180))/2)
    + COS(:latitude * (PI()/180) * COS(s.latitude * (PI()/180)
    * SIN(((:longitude - s.longitude) * (PI()/180))/2) * SIN(((:longitude - s.longitude) * (PI()/180))/2))))))))
    AS distance
SELECT
);
            $qb->orderBy('distance');
            $qb->setParameter('latitude', $this->get('latitude'));
            $qb->setParameter('longitude', $this->get('longitude'));
        }
    }
开发者ID:comphppuebla,项目名称:echale-gas-api,代码行数:22,代码来源:GeolocationSpecification.php

示例8: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     if (!$this->includeInactiveUsers) {
         $query->andWhere('u.uIsActive = :uIsActive');
         $query->setParameter('uIsActive', true);
     }
     if (!$this->includeUnvalidatedUsers) {
         $query->andWhere('u.uIsValidated != 0');
     }
     return $query;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:11,代码来源:UserList.php

示例9: setValuesAndParameters

 /**
  * Sets the values and parameters of the upcoming given query according
  * to the entity.
  *
  * @param Entity $entity
  * the entity with its fields and values
  * @param QueryBuilder $queryBuilder
  * the upcoming query
  * @param string $setMethod
  * what method to use on the QueryBuilder: 'setValue' or 'set'
  */
 protected function setValuesAndParameters(Entity $entity, QueryBuilder $queryBuilder, $setMethod)
 {
     $formFields = $this->getFormFields();
     $count = count($formFields);
     for ($i = 0; $i < $count; ++$i) {
         $type = $this->definition->getType($formFields[$i]);
         $value = $entity->get($formFields[$i]);
         if ($type == 'boolean') {
             $value = $value ? 1 : 0;
         }
         $queryBuilder->{$setMethod}('`' . $formFields[$i] . '`', '?');
         $queryBuilder->setParameter($i, $value);
     }
 }
开发者ID:philiplb,项目名称:crudlex,代码行数:25,代码来源:MySQLData.php

示例10: buildQuery

 /**
  * {@inheritdoc}
  */
 public function buildQuery(QueryBuilder $queryBuilder, array $values = array())
 {
     if (!array_key_exists($this->getName(), $values) || 0 === count($values[$this->getName()])) {
         return;
     }
     $codes = $values[$this->getName()];
     if (in_array('all_but_paris', $codes)) {
         $departements = new Departments();
         $regions = new Regions();
         unset($codes[array_search('all_but_paris', $codes)]);
         $codes = array_merge($codes, array_diff(array_keys($departements->getArrayCopy()), $regions->get(self::ALL_BUT_PARIS_REGION_CODE)->getCodesDepartements()));
     }
     if (count($codes)) {
         $queryBuilder->setParameter('department', $codes, Connection::PARAM_STR_ARRAY)->andWhere('response.companyDepartment IN(:department)');
     }
 }
开发者ID:Volyz,项目名称:barometre,代码行数:19,代码来源:DepartmentFilter.php

示例11: setValuesAndParameters

 /**
  * Sets the values and parameters of the upcoming given query according
  * to the entity.
  *
  * @param CRUDEntity $entity
  * the entity with its fields and values
  * @param QueryBuilder $queryBuilder
  * the upcoming query
  * @param boolean $setValue
  * whether to use QueryBuilder::setValue (true) or QueryBuilder::set (false)
  */
 protected function setValuesAndParameters(CRUDEntity $entity, QueryBuilder $queryBuilder, $setValue)
 {
     $formFields = $this->definition->getEditableFieldNames();
     $count = count($formFields);
     for ($i = 0; $i < $count; ++$i) {
         $value = $entity->get($formFields[$i]);
         $type = $this->definition->getType($formFields[$i]);
         if ($type == 'bool') {
             $value = $value ? 1 : 0;
         }
         if ($type == 'date' || $type == 'datetime' || $type == 'reference') {
             $value = $value == '' ? null : $value;
         }
         if ($setValue) {
             $queryBuilder->setValue('`' . $formFields[$i] . '`', '?');
         } else {
             $queryBuilder->set('`' . $formFields[$i] . '`', '?');
         }
         $queryBuilder->setParameter($i, $value);
     }
 }
开发者ID:timfreiheit,项目名称:CRUDlex,代码行数:32,代码来源:CRUDMySQLData.php

示例12: applyFilters

 /**
  * @param array        $filters
  * @param QueryBuilder $queryBuilder
  * @param array        $filterDefinitions
  *
  * @return bool
  */
 private function applyFilters(array $filters, QueryBuilder $queryBuilder, array $filterDefinitions)
 {
     $expr = $queryBuilder->expr();
     $filterExpr = $expr->andX();
     if (count($filters)) {
         foreach ($filters as $filter) {
             $exprFunction = isset($filter['expr']) ? $filter['expr'] : $filter['condition'];
             $paramName = InputHelper::alphanum($filter['column']);
             switch ($exprFunction) {
                 case 'notEmpty':
                     $filterExpr->add($expr->isNotNull($filter['column']));
                     $filterExpr->add($expr->neq($filter['column'], $expr->literal('')));
                     break;
                 case 'empty':
                     $filterExpr->add($expr->isNull($filter['column']));
                     $filterExpr->add($expr->eq($filter['column'], $expr->literal('')));
                     break;
                 default:
                     if (trim($filter['value']) == '') {
                         // Ignore empty
                         break;
                     }
                     $columnValue = ":{$paramName}";
                     switch ($filterDefinitions[$filter['column']]['type']) {
                         case 'bool':
                         case 'boolean':
                             if ((int) $filter['value'] > 1) {
                                 // Ignore the "reset" value of "2"
                                 break;
                             }
                             $queryBuilder->setParameter($paramName, $filter['value'], 'boolean');
                             break;
                         case 'float':
                             $columnValue = (double) $filter['value'];
                             break;
                         case 'int':
                         case 'integer':
                             $columnValue = (int) $filter['value'];
                             break;
                         default:
                             $queryBuilder->setParameter($paramName, $filter['value']);
                     }
                     $filterExpr->add($expr->{$exprFunction}($filter['column'], $columnValue));
             }
         }
     }
     if ($filterExpr->count()) {
         $queryBuilder->andWhere($filterExpr);
         return true;
     }
     return false;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:59,代码来源:MauticReportBuilder.php

示例13: prepareConditions

 /**
  * @param QueryBuilder $query
  * @return QueryBuilder
  */
 protected function prepareConditions($query)
 {
     $i = 0;
     if (count($this->getConditions()) !== 0) {
         foreach ($this->getConditions() as $condition) {
             $conditionKey = 'NNXGridCondition_' . $i;
             $query->andWhere($condition->getKey() . ' ' . $condition->getCriteria() . ' :' . $conditionKey);
             $query->setParameter($conditionKey, $condition->getValue());
             $i++;
         }
     }
     return $query;
 }
开发者ID:nnx-framework,项目名称:data-grid,代码行数:17,代码来源:DoctrineDBAL.php

示例14: notEquals

 /**
  * {@inheritdoc}
  */
 public function notEquals($field, $value)
 {
     $this->queryBuilder->setParameter($field, $value);
     return $this->queryBuilder->expr()->neq($field, ':' . $field);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:8,代码来源:ExpressionBuilder.php

示例15: modifyCountDateDiffQuery

 /**
  * Modify the query to count how many rows is between a range of date diff in seconds
  *
  * @param  QueryBuilder $query
  * @param  string       $dateColumn1
  * @param  string       $dateColumn2
  * @param  integer      $startSecond
  * @param  integer      $endSecond
  * @param  array        $filters will be added to where claues
  * @param  string       $tablePrefix
  */
 public function modifyCountDateDiffQuery(QueryBuilder &$query, $dateColumn1, $dateColumn2, $startSecond = 0, $endSecond = 60, $tablePrefix = 't')
 {
     $query->select('COUNT(' . $tablePrefix . '.' . $dateColumn1 . ') AS count');
     $query->where('TIMESTAMPDIFF(SECOND, ' . $tablePrefix . '.' . $dateColumn1 . ', ' . $tablePrefix . '.' . $dateColumn2 . ') >= :startSecond');
     $query->andWhere('TIMESTAMPDIFF(SECOND, ' . $tablePrefix . '.' . $dateColumn1 . ', ' . $tablePrefix . '.' . $dateColumn2 . ') < :endSecond');
     $query->setParameter('startSecond', $startSecond);
     $query->setParameter('endSecond', $endSecond);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:19,代码来源:ChartQuery.php


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