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


PHP QueryBuilder::select方法代码示例

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


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

示例1: testBeforeGetList

 /**
  * @dataProvider beforeGetListHarness
  */
 public function testBeforeGetList($query, $expectedQuery, $expectedParams)
 {
     $this->queryBuilder->select('o.*')->from('posts', 'o');
     $request = new Request($query);
     $queryBuilder = $this->postDecorator->beforeGetList($this->queryBuilder, $request);
     $this->assertEquals($expectedQuery, (string) $queryBuilder);
     $this->assertEquals($expectedParams, $queryBuilder->getParameters());
 }
开发者ID:scottie34,项目名称:silex-fwk,代码行数:11,代码来源:PostDecorator_BeforeGetListTest.php

示例2: setUp

 protected function setUp()
 {
     if ($this->isDoctrineDbalNotAvailable()) {
         $this->markTestSkipped('Doctrine DBAL is not available');
     }
     $conn = $this->getConnection();
     $this->createSchema($conn);
     $this->insertData($conn);
     $this->qb = new QueryBuilder($conn);
     $this->qb->select('p.*')->from('posts', 'p');
 }
开发者ID:hidayat365,项目名称:phpindonesia.or.id-membership2,代码行数:11,代码来源:DoctrineDbalTestCase.php

示例3: testPaginationWithDoctrineDbalAdapter

 public function testPaginationWithDoctrineDbalAdapter()
 {
     $cqb = clone $this->qb;
     $records = $this->qb->select('*')->from('sample', 'sample');
     $cqb->select('*')->from('sample', 'sample')->setMaxResults(20)->setFirstResult(60);
     $expected = $cqb->execute()->fetchAll();
     /*var_dump($this->qb->execute()->fetchAll());
       exit;*/
     $paginatorClass = new Paginator();
     $paginator = $paginatorClass->page(4)->perPage(20)->make($records);
     $this->assertEquals(90, $paginator->total(), 'Failed asserting pagination total.');
     $this->assertEquals($expected, $paginator->records(), 'Failed asserting pagination records.');
 }
开发者ID:atiarda,项目名称:strana,代码行数:13,代码来源:DoctrineDbalTest.php

示例4: __construct

 /**
  * @param QueryBuilder  $qb
  * @param callable|null $countQueryBuilderModifier
  */
 public function __construct(QueryBuilder $qb, callable $countQueryBuilderModifier = null)
 {
     $this->qb = $qb;
     $this->countQueryBuilderModifier = $countQueryBuilderModifier ?: function (QueryBuilder $qb) {
         return $qb->select('COUNT(*)');
     };
 }
开发者ID:kbond,项目名称:porpaginas,代码行数:11,代码来源:DBALQueryBuilderResult.php

示例5: selectDoesNotQuoteStarPlaceholder

 /**
  * @test
  */
 public function selectDoesNotQuoteStarPlaceholder()
 {
     $this->connection->quoteIdentifier('aField')->shouldBeCalled()->willReturnArgument(0);
     $this->connection->quoteIdentifier('*')->shouldNotBeCalled();
     $this->concreteQueryBuilder->select(Argument::exact('aField'), Argument::exact('*'))->shouldBeCalled()->willReturn($this->subject);
     $this->subject->select('aField', '*');
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:10,代码来源:QueryBuilderTest.php

示例6: getFilteredCountQuery

 /**
  * Build the count of filtered query
  *
  * @return QueryBuilder
  */
 public function getFilteredCountQuery()
 {
     $this->buildFilteredQuery();
     $this->currentQueryBuilder->select('COUNT(DISTINCT ' . $this->getDistinct() . ')');
     $this->currentQueryBuilder->resetQueryPart('orderBy');
     return $this->currentQueryBuilder;
 }
开发者ID:solire,项目名称:trieur,代码行数:12,代码来源:Doctrine.php

示例7: testSetQueryBuilder02

 public function testSetQueryBuilder02()
 {
     $contain = $this->testConstruct02();
     $queryBuilder = new QueryBuilder($this->getConnection());
     $queryBuilder->select('*')->from('table', 't');
     $contain->setQueryBuilder($queryBuilder);
     return $contain;
 }
开发者ID:solire,项目名称:trieur,代码行数:8,代码来源:Contain.php

示例8: getDataProvider

 protected function getDataProvider()
 {
     if (!$this->provider) {
         $builder = new QueryBuilder(Connection::get());
         $builder->select('*')->from('test_users');
         $this->provider = new DoctrineDataProvider($builder);
     }
     return $this->provider;
 }
开发者ID:view-components,项目名称:doctrine-data-processing,代码行数:9,代码来源:DoctrineTestTrait.php

示例9: testItShouldWorksWithParametersInTheOrX

 public function testItShouldWorksWithParametersInTheOrX()
 {
     $qb = new QueryBuilder($this->connection);
     $qb->select('p.id')->from('posts', 'p')->setParameter('status', 'odd');
     $aclFilter = new DoctrineDbalAclFilter($qb);
     $aclFilter->setAclSchema($this->aclSchema);
     $aclFilter->apply('p', 'id', 'post-', ['user-1'], 1, ['status = :status']);
     $this->assertEquals(['status' => 'odd', 'acl_prefix' => 'post-', 'acl_identifiers' => ['user-1'], 'acl_mask' => 1], $qb->getParameters());
 }
开发者ID:alexdpy,项目名称:acl,代码行数:9,代码来源:DoctrineDbalAclFilterTest.php

示例10: loadUserByUsername

 /**
  * Load user by username
  * 
  * @param string $username
  * @return User
  * @throws \Exception
  */
 public function loadUserByUsername($username)
 {
     $qb = new QueryBuilder($this->db);
     $stmt = $qb->select('username, password, roles')->from('users', 'u')->where('u.username = :username')->andWhere('u.active = 1')->setParameter('username', $username)->execute();
     if (!($user = $stmt->fetchObject())) {
         throw new \Exception(sprintf('User "%s" not found.', $username));
     }
     return new User($user->username, $user->password, explode(',', $user->roles), true, true, true, true);
 }
开发者ID:avlima,项目名称:silexmantic-skeleton,代码行数:16,代码来源:UserProvider.php

示例11: 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

示例12: 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

示例13: shouldPaginateSimpleDoctrineQuery

 /**
  * @test
  */
 function shouldPaginateSimpleDoctrineQuery()
 {
     $this->populate();
     $p = new Paginator();
     $qb = new QueryBuilder($this->em->getConnection());
     $qb->select('*')->from('Article', 'a');
     $view = $p->paginate($qb, 1, 2);
     $this->assertEquals(1, $view->getCurrentPageNumber());
     $this->assertEquals(2, $view->getItemNumberPerPage());
     $this->assertEquals(4, $view->getTotalItemCount());
     $items = $view->getItems();
     $this->assertEquals(2, count($items));
     $this->assertEquals('summer', $items[0]['title']);
     $this->assertEquals('winter', $items[1]['title']);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:18,代码来源:DBALQueryBuilderTest.php

示例14: _build

 /**
  * 初始化数据构造器
  *
  * @param  int $type 要执行的SQL类型
  * @return $this
  */
 protected function _build($type)
 {
     switch ($type) {
         case Db::SELECT:
             $this->_dbBuilder = $this->_db->createQueryBuilder()->select();
             break;
         case Db::UPDATE:
             $this->_dbBuilder = $this->_db->createQueryBuilder()->update($this->_tableName, $this->_objectName);
             break;
         case Db::DELETE:
             $this->_dbBuilder = $this->_db->createQueryBuilder()->delete($this->_tableName);
     }
     $selectList = [];
     foreach ($this->_dbPending as $method) {
         $name = $method['name'];
         $args = $method['args'];
         // 如果是select,那么暂时先不执行
         if ($name == 'select') {
             $selectList = Arr::merge($selectList, $args);
             continue;
         }
         $this->_dbApplied[$name] = $name;
         call_user_func_array([$this->_dbBuilder, $name], $args);
     }
     $this->_dbBuilder->select($selectList);
     return $this;
 }
开发者ID:tourze,项目名称:model,代码行数:33,代码来源:Model.php

示例15: testCreatePositionalParameter

 public function testCreatePositionalParameter()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('u.*')->from('users', 'u')->where($qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT)));
     $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string) $qb);
     $this->assertEquals(10, $qb->getParameter(1));
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:7,代码来源:QueryBuilderTest.php


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