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


PHP QueryBuilder::execute方法代码示例

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


在下文中一共展示了QueryBuilder::execute方法的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: getResults

 /**
  * @param int $page Starts at 1
  * @param bool $allResults
  * @return DataObjectInterface[]
  */
 public function getResults($page, $allResults = false)
 {
     if ($page < 1 || $page > $this->getPages()) {
         throw new InvalidArgumentException("Page must be between 1 and {$this->getPages()}");
     }
     if (!$allResults) {
         $this->page = $page;
         $this->prev = $page > 1 ? $page - 1 : 0;
         $this->next = $page < $this->pages ? $page + 1 : 0;
         $this->qb->setMaxResults($this->pageSize)->setFirstResult(($page - 1) * $this->pageSize);
     }
     $statement = $this->qb->execute();
     return $statement->fetchAll(\PDO::FETCH_CLASS, $this->class, $this->dependencies);
 }
开发者ID:thewunder,项目名称:corma,代码行数:19,代码来源:PagedQuery.php

示例3: execute

 public function execute()
 {
     foreach ($this->conditions as $field => $value) {
         $this->setParameter(":{$field}", $value);
     }
     return parent::execute();
 }
开发者ID:codeages,项目名称:biz-framework,代码行数:7,代码来源:DynamicQueryBuilder.php

示例4: setUp

 public function setUp()
 {
     $builder = new QueryBuilder(Connection::get());
     $builder->select('*')->from('test_users');
     $this->data = $builder->execute()->fetchAll(\PDO::FETCH_OBJ);
     $this->operations = new OperationCollection();
     $this->service = new DoctrineProcessingService(new DoctrineProcessorResolver(), $this->operations, $builder);
     $this->totalCount = (new QueryBuilder(Connection::get()))->select('count(*)')->from('test_users')->execute()->fetchColumn();
     self::assertTrue($this->totalCount > 0);
 }
开发者ID:view-components,项目名称:doctrine-data-processing,代码行数:10,代码来源:DoctrineProcessingServiceTest.php

示例5: executeSelectQuery

 /**
  * @param QueryBuilder $query
  * @return array
  */
 protected function executeSelectQuery(QueryBuilder $query)
 {
     $rows = array();
     $statement = $query->execute();
     /** @todo Should configure which fetch method to use (fetch row by row or fetchAll) */
     while (($row = $statement->fetch(PDO::FETCH_ASSOC)) !== false) {
         $this->processRow($row, $rows);
     }
     $rows = $this->processRows($rows);
     return $this->denormalizeRows($rows);
 }
开发者ID:detailnet,项目名称:dfw-importing,代码行数:15,代码来源:DBALSourceBasedRepository.php

示例6: setDBALQuery

 /**
  * Prepare listing instance from Doctrine DBAL QueryBuilder.
  * 
  * Total rows count for Listing instance must be set separately.
  * 
  * @param DBALQueryBuilder
  * @param boolean
  * @param boolean
  * @return self
  */
 public function setDBALQuery(DBALQueryBuilder $query, $appendLimit = true, $appendOrder = true)
 {
     if ($appendLimit) {
         $query->setFirstResult($this->offset())->setMaxResults($this->limit());
     }
     if ($appendOrder && $this->order()) {
         call_user_func_array([$query, 'orderBy'], (array) $this->order());
     }
     $this->setItems($query->execute()->fetchAll());
     return $this;
 }
开发者ID:minchal,项目名称:vero,代码行数:21,代码来源:DoctrineListing.php

示例7: run

 /**
  * @return array
  */
 protected function run()
 {
     if (!$this->result || $this->queryBuilder->getState() === QueryBuilder::STATE_DIRTY) {
         $statement = $this->queryBuilder->execute();
         $statement->setFetchMode(\PDO::FETCH_ASSOC);
         $rows = $statement->fetchAll();
         $statement->closeCursor();
         $this->result = $this->mapper ? $this->mapper->collection($rows) : $rows;
     }
     return $this->result;
 }
开发者ID:marcojetson,项目名称:freckle,代码行数:14,代码来源:Query.php

示例8: getFilteredPostsIds

 protected function getFilteredPostsIds(array $identifiers, $mask, array $orX = [])
 {
     $qb = new QueryBuilder($this->connection);
     $qb->select('p.id')->from('posts', 'p');
     $aclFilter = new DoctrineDbalAclFilter($qb);
     $aclFilter->setAclSchema($this->aclSchema);
     $aclFilter->apply('p', 'id', 'post-', $identifiers, $mask, $orX);
     $result = array_map(function ($post) {
         return (int) $post['id'];
     }, $qb->execute()->fetchAll());
     return [$result];
 }
开发者ID:alexdpy,项目名称:acl,代码行数:12,代码来源:DoctrineDbalAclFilterTest.php

示例9: loadRoles

 /**
  * Load roles at RBAC creation.
  *
  * @param Event $e
  * @return array
  */
 public function loadRoles(Event $e)
 {
     $builder = new QueryBuilder($this->connection);
     $options = $this->options;
     $builder->select("role.{$options->getNameColumn()} AS name, parent.{$options->getNameColumn()} AS parent")->from($options->getTable(), 'role')->leftJoin('role', $options->getTable(), 'parent', "role.{$options->getJoinColumn()} = parent.{$options->getIdColumn()}");
     $result = $builder->execute();
     $roles = array();
     foreach ($result as $row) {
         $parentName = isset($row['parent']) ? $row['parent'] : 0;
         unset($row['parent']);
         $roles[$parentName][] = $row['name'];
     }
     $this->recursiveRoles($e->getRbac(), $roles);
 }
开发者ID:Mystraht,项目名称:builder,代码行数:20,代码来源:DoctrineDbal.php

示例10: rewind

 /**
  * Rewind
  */
 public function rewind()
 {
     //Only perform rewind if current item is not the first element
     if ($this->currentKey !== 0) {
         $this->batchPosition = 0;
         $this->queryBuilder->setFirstResult(0);
         $this->queryBuilder->setMaxResults($this->batchSize);
         /* @var $stmt \Doctrine\DBAL\Statement */
         $stmt = $this->queryBuilder->execute();
         $stmt->setFetchMode(\PDO::FETCH_ASSOC);
         $this->currentItem = null;
         $this->currentKey = -1;
         $this->statement = $stmt;
         $this->next();
     }
 }
开发者ID:prooph,项目名称:event-store-doctrine-adapter,代码行数:19,代码来源:DoctrineStreamIterator.php

示例11: getReferers

 /**
  * Get list of referers ordered by it's count
  *
  * @param \Doctrine\DBAL\Query\QueryBuilder $query
  * @param int                               $limit
  * @param int                               $offset
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getReferers($query, $limit = 10, $offset = 0)
 {
     $query->select('h.referer, count(h.referer) as sessions')->groupBy('h.referer')->orderBy('sessions', 'DESC')->setMaxResults($limit)->setFirstResult($offset);
     return $query->execute()->fetchAll();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:16,代码来源:VideoHitRepository.php

示例12: getMostVisited

 /**
  * Get list of referers ordered by it's count
  *
  * @param \Doctrine\DBAL\Query\QueryBuilder $query
  * @param int                               $limit
  * @param int                               $offset
  * @param string                            $column
  * @param string                            $as
  *
  * @return array
  * @throws \Doctrine\ORM\NoResultException
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function getMostVisited($query, $limit = 10, $offset = 0, $column = 'p.hits', $as = '')
 {
     if ($as) {
         $as = ' as "' . $as . '"';
     }
     $query->select('p.title, p.id, ' . $column . $as)->groupBy('p.id, p.title, ' . $column)->orderBy($column, 'DESC')->setMaxResults($limit)->setFirstResult($offset);
     return $query->execute()->fetchAll();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:21,代码来源:HitRepository.php

示例13: make

 /**
  * @param array $request
  * @return array
  */
 public function make(array $request)
 {
     $output = ['data' => [], 'draw' => $request['draw'], 'recordsFiltered' => 0, 'recordsTotal' => 0];
     /**
      * Order By
      */
     if (isset($request['order'])) {
         for ($i = 0; $i < count($request['order']); ++$i) {
             $j = intval($request['order'][$i]['column']);
             if ($request['columns'][$j]['orderable'] != 'true') {
                 continue;
             }
             $column = $request['columns'][$j]['data'];
             $sort = $request['order'][$i]['dir'];
             $this->query->addOrderBy($column, $sort);
         }
     }
     /**
      * Count All
      */
     $temp = clone $this->query;
     $temp->resetQueryPart('select');
     $temp->resetQueryPart('orderBy');
     $temp->select("COUNT(*)");
     $output['recordsTotal'] = $temp->execute()->fetchColumn(0);
     /**
      * Filter
      */
     for ($i = 0; $i < count($request['columns']); ++$i) {
         if ($request['columns'][$i]['searchable'] != 'true') {
             continue;
         }
         $value = $request['columns'][$i]['search']['value'];
         if (strlen($value) > 0) {
             $column = $request['columns'][$i]['data'];
             $value = $this->query->getConnection()->quote("{$value}%");
             $this->query->andHaving($this->query->expr()->like($column, $value));
         }
     }
     /**
      * Search
      */
     if (isset($request['search'])) {
         $value = $request['search']['value'];
         if (strlen($value) > 0) {
             for ($i = 0; $i < count($request['columns']); ++$i) {
                 if ($request['columns'][$i]['searchable'] != 'true') {
                     continue;
                 }
                 $column = $request['columns'][$i]['data'];
                 $this->query->orHaving($this->query->expr()->like($column, ':search'));
             }
             $this->query->setParameter('search', "%{$value}%");
         }
     }
     /**
      * Count Filtered
      */
     $temp = clone $this->query;
     $temp->resetQueryPart('orderBy');
     $output['recordsFiltered'] = $temp->execute()->rowCount();
     /**
      * Limit
      */
     if (isset($request['start'])) {
         $this->query->setFirstResult($request['start']);
     }
     if (isset($request['length'])) {
         $this->query->setMaxResults($request['length']);
     }
     /**
      * Fetch Results
      */
     $output['data'] = $this->query->execute()->fetchAll(\PDO::FETCH_ASSOC);
     /**
      * Add Filter
      */
     return $output;
 }
开发者ID:vaibhavpandeyvpz,项目名称:acraviz,代码行数:83,代码来源:Datatables.php

示例14: findOneWith

 /**
  * Internal method to hydrate and return a single QueryBuilder result
  *
  * @return Entity | false
  **/
 protected function findOneWith(QueryBuilder $query)
 {
     $result = $query->execute()->fetch();
     if ($result) {
         return $this->hydrate($result, $query);
     } else {
         return false;
     }
 }
开发者ID:Johardmeier,项目名称:bolt,代码行数:14,代码来源:Repository.php

示例15: afterOperations

 /**
  * @param QueryBuilder $data
  * @return Traversable
  */
 protected function afterOperations($data)
 {
     return new ArrayIterator($data->execute()->fetchAll(PDO::FETCH_OBJ));
 }
开发者ID:view-components,项目名称:doctrine-data-processing,代码行数:8,代码来源:DoctrineProcessingService.php


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