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


PHP QueryBuilder::select方法代码示例

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


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

示例1: should_create_complex_query

 /**
  * @test
  */
 public function should_create_complex_query()
 {
     $specification = $this->userSpecificationFactory->status('approved')->orX($this->userSpecificationFactory->status('declined')->andX($this->userSpecificationFactory->name('John')));
     $this->queryBuilder->select('user')->from('User', 'user')->where($specification->expr())->setParameters($specification->parameters());
     $this->assertEquals(['status_1' => 'approved', 'status_2' => 'declined', 'name_3' => 'John'], $specification->parameters());
     $this->assertEquals('SELECT user FROM User user WHERE user.status = :status_1 OR (user.status = :status_2 AND user.name = :name_3)', $this->queryBuilder->getDQL());
 }
开发者ID:gidman,项目名称:nexode-specification,代码行数:10,代码来源:SimpleSpecTest.php

示例2: searchOne

 /**
  * @param ChannelConditionInterface $condition
  * @return ChannelInterface
  */
 public function searchOne(ChannelConditionInterface $condition)
 {
     $this->qb = $this->em->createQueryBuilder();
     $this->qb->select('ch')->from('CoreBundle:Channel', 'ch');
     $this->initQueryBuilder($condition);
     return $this->qb->getQuery()->getOneOrNullResult();
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:11,代码来源:ChannelManager.php

示例3: __construct

 /**
  * Constructor.
  * 
  * @access   public
  * @param    ORM\QueryBuilder $query
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function __construct(ORM\QueryBuilder $query)
 {
     $this->query = $query;
     $this->oCountingQuery = clone $this->query;
     $this->oCountingQuery->select('COUNT(DISTINCT t.id)');
     $this->iCount = $this->getCountingQuery()->single();
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:15,代码来源:SearchEngineGeneratedQueries.php

示例4: __construct

 /**
  * Constructor
  *
  * @param EntityManager $manager
  * @param string        $class
  */
 public function __construct(EntityManager $manager, $class)
 {
     $this->manager = $manager;
     $this->metadata = $manager->getClassMetadata($class);
     $this->qBuilder = $manager->createQueryBuilder();
     $this->qBuilder->select('e')->from($class, 'e');
 }
开发者ID:sunnyct,项目名称:silexcmf-doctrine,代码行数:13,代码来源:ORMQueryBuilder.php

示例5: search

 /**
  * @param CompanyConditionInterface $condition
  * @return Company[]
  */
 public function search(CompanyConditionInterface $condition)
 {
     $this->qb = $this->em->createQueryBuilder();
     $this->qb->select('co')->from('CoreBundle:Company', 'co');
     $this->initQueryBuilder($condition);
     $this->preparePagination($this->qb, $condition);
     return $this->qb->getQuery()->getResult();
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:12,代码来源:CompanyManager.php

示例6: searchArticlesByTags

 /**
  * Return an article array by tag
  * @param $strings
  * @return array
  */
 public function searchArticlesByTags($strings)
 {
     $strings = $this->setCleanRequest($strings);
     $this->qb->select('t')->from('AppBundle:Tag', 't')->where('t.slug LIKE :strings')->addOrderBy('t.frequency', 'DESC')->setParameter('strings', $strings);
     $q = $this->qb->getQuery();
     $tags = $q->getResult();
     $articlesArray = array();
     foreach ($tags as $tag) {
         $articles = $tag->getArticles();
         foreach ($articles as $article) {
             array_push($articlesArray, $article);
         }
     }
     return $articlesArray;
 }
开发者ID:baptistelinel,项目名称:Administrable-Blog,代码行数:20,代码来源:SearchService.php

示例7: buildCount

 public function buildCount(QueryBuilder $queryBuilder) : Query
 {
     if (!empty($this->name)) {
         $queryBuilder->where($queryBuilder->expr()->like('o.name.name', ':name'))->setParameter('name', '%' . $this->name . '%');
     }
     return $queryBuilder->select($queryBuilder->expr()->count('o.id'))->from(Organization::class, 'o')->leftJoin('o.organizationMembers', 'om')->leftJoin('o.owners', 'ow')->andWhere($queryBuilder->expr()->orX($queryBuilder->expr()->eq('om.userId', ':userId'), $queryBuilder->expr()->eq('ow.userId', ':userId')))->setParameter('userId', $this->userId->id())->getQuery();
 }
开发者ID:kreta,项目名称:kreta,代码行数:7,代码来源:DoctrineORMNameFilterableSpecification.php

示例8: homeAction

    /**
     * @route: blog_home
     * Homepage controller
     */
    public function homeAction()
    {
        // entity manager
        $em = $this->getEm();
        
        $qb = new QueryBuilder($em);
        // dql query
        $qb->select('p,c,t')
            ->from('Bundle\BlogBundle\Entity\Post', 'p')
            ->join('p.category', 'c')
            ->join('p.tags', 't')
            ->orderBy('p.date', 'DESC');
        // array of objects
        $posts = $qb->getQuery()->getResult();

        $query = $em->createQuery('SELECT c,p FROM Bundle\BlogBundle\Entity\Category c JOIN c.posts p');
        $categories = $query->getResult();

        $query = $em->createQuery('SELECT t,p FROM Bundle\BlogBundle\Entity\Tag t JOIN t.posts p');
        $tags = $query->getResult();

        return $this->render('BlogBundle:Blog:homepage.html.twig', array(
            'posts' => $posts,
            'categories' => $categories,
            'tags' => $tags
        ));
    }
开发者ID:rdbsf,项目名称:BlogBundle,代码行数:31,代码来源:BlogController.php

示例9: getFilteredCountQuery

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

示例10: leftMenuAction

 /**
  * @extra:Route("/", name="_alf")
  * @extra:Template()
  */
 public function leftMenuAction()
 {
     //        $catalog = new Catalogs();
     //        $catalog->setCategory('1');
     //        $catalog->setName('skarpety wpisane');
     //        $em = $this->get('doctrine.orm.entity_manager');
     //        $em->persist($catalog);
     //        $em->flush();
     //        $menu = $this->get('doctrine.orm.entity_manager')
     //            ->createQuery('SELECT c FROM AlfShopBundle:Catalogs c ORDER BY c.id DESC')
     //            ->getResult()
     //            ;
     //        $menu = array( array('name' => 'A'), array('name' => 'B'),array('name' => 'C'));
     $em = $this->get('doctrine.orm.entity_manager');
     $qb = new QueryBuilder($em);
     $dql = $qb->select('c.name')->from('AlfShopBundle:Catalogs', 'c')->getQuery();
     $menu = $dql->getResult();
     $em = $this->get('doctrine.orm.entity_manager');
     $qb = new QueryBuilder($em);
     $dql = $qb->select('c')->from('AlfShopBundle:Catalogs', 'c');
     $query = $em->createQuery($dql);
     $adapter = $this->get('knplabs_paginator.adapter');
     $adapter->setQuery($query);
     $adapter->setDistinct(true);
     $paginator = new \Zend\Paginator\Paginator($adapter);
     $paginator->setCurrentPageNumber($this->get('request')->query->get('page', 1));
     $paginator->setItemCountPerPage(2);
     $paginator->setPageRange(5);
     //        $menu = $m ->getResult();
     //        $menu = $em->find('AlfShopBundle:Catalogs');
     //        $em->persist($menu);
     //        $em->flush();
     //        $menu = array('A', 'B');
     return $this->render('AlfShopBundle:Shop:leftMenu.html.twig', array('menuList' => $paginator, 'paginator' => $paginator));
 }
开发者ID:radzikowski,项目名称:alf,代码行数:39,代码来源:ShopController.php

示例11: buildDataRequestQuery

 /**
  * Builds the query for the given data request object
  * 
  * @access public
  * @param \Zepi\DataSource\Core\Entity\DataRequest $dataRequest
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder
  * @param string $entity
  * @param string $tableCode
  */
 public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode)
 {
     $queryBuilder->select($tableCode)->from($entity, $tableCode);
     $hasWhere = false;
     $i = 1;
     foreach ($dataRequest->getFilters() as $filter) {
         $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :' . $i;
         if ($hasWhere) {
             $queryBuilder->andWhere($whereQuery);
         } else {
             $queryBuilder->where($whereQuery);
             $hasWhere = true;
         }
         $queryBuilder->setParameter($i, $filter->getNeededValue());
         $i++;
     }
     // Sorting
     if ($dataRequest->hasSorting()) {
         $mode = 'ASC';
         if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) {
             $mode = $dataRequest->getSortByDirection();
         }
         $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode);
     }
     // Offset
     if ($dataRequest->hasRange()) {
         $queryBuilder->setFirstResult($dataRequest->getOffset());
         $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries());
     }
 }
开发者ID:zepi,项目名称:turbo-base,代码行数:39,代码来源:EntityManager.php

示例12: implement

 public function implement(DoctrineQueryBuilder $queryBuilder)
 {
     if (!$this->getValue()) {
         return $queryBuilder;
     }
     $queryBuilder->select('COUNT(' . QueryBuilder::DEFAULT_ALIAS . '.id)');
 }
开发者ID:jacoz,项目名称:doctrine-query-builder-from-request,代码行数:7,代码来源:CountParam.php

示例13: getQueryBuilder

 public function getQueryBuilder()
 {
     if (!$this->queryBuilder) {
         $this->queryBuilder = $this->em->createQueryBuilder();
         $this->queryBuilder->select('root')->from($this->getClassMetadata()->getName(), 'root');
     }
     return $this->queryBuilder;
 }
开发者ID:o3co,项目名称:query,代码行数:8,代码来源:ExpressionVisitor.php

示例14: selectListQuery

 /**
  * Helper function which sets the fromPath and the selectPath for the order list query.
  * @param \Doctrine\ORM\QueryBuilder $builder
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function selectListQuery(\Doctrine\ORM\QueryBuilder $builder)
 {
     //select the different entities
     $builder->select(array('documents.id as id', 'documents.date as date', 'documents.typeId as typeId', 'documents.customerId as customerId', 'documents.orderId as orderId', 'documents.amount as amount', 'documents.documentId as documentId', 'documents.hash as hash', 'type.name as typeName'));
     //join the required tables for the order list
     $builder->from('Shopware\\Models\\Order\\Document\\Document', 'documents')->join('documents.type', 'type');
     return $builder;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:13,代码来源:Repository.php

示例15: testAddDatePartsSelect

 /**
  * @dataProvider addDatePartsSelectProvider
  */
 public function testAddDatePartsSelect($start, $end, $expects)
 {
     $start = new \DateTime($start, new \DateTimeZone('UTC'));
     $end = new \DateTime($end, new \DateTimeZone('UTC'));
     $queryBuilder = new QueryBuilder($this->getTestEntityManager());
     $queryBuilder->select('id')->from('Oro\\Bundle\\DashboardBundle\\Tests\\Unit\\Fixtures\\FirstTestBundle\\Entity\\TestEntity', 't');
     $this->helper->addDatePartsSelect($start, $end, $queryBuilder, 't.createdAt');
     $this->assertEquals($expects, $queryBuilder->getDQL());
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:DateHelperTest.php


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