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


PHP QueryBuilder::from方法代码示例

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


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

示例1: buildQuery

 /**
  * Builds the raw query
  *
  * @return void
  */
 protected function buildQuery()
 {
     $this->queryBuilder = $this->connection->createQueryBuilder();
     $this->queryBuilder->select((array) $this->conf->select);
     /*
      * Main table
      */
     $this->queryBuilder->from($this->conf->from->name, $this->conf->from->alias);
     /*
      * Inner join, right join, left join
      */
     $joinTypes = ['innerJoin', 'leftJoin', 'rightJoin'];
     foreach ($joinTypes as $joinType) {
         if (isset($this->conf->{$joinType})) {
             $joins = $this->conf->{$joinType};
             $this->buildJoins($joinType, $joins);
         }
     }
     /*
      * Condition
      */
     if (isset($this->conf->where)) {
         foreach ($this->conf->where as $where) {
             $this->queryBuilder->andWhere($where);
         }
     }
 }
开发者ID:solire,项目名称:trieur,代码行数:32,代码来源:Doctrine.php

示例2: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     if ($this->includeAliases) {
         $query->from('Pages', 'p')->leftJoin('p', 'Pages', 'pa', 'p.cPointerID = pa.cID')->leftJoin('p', 'PagePaths', 'pp', 'p.cID = pp.cID and pp.ppIsCanonical = true')->leftJoin('pa', 'PageSearchIndex', 'psi', 'psi.cID = if(pa.cID is null, p.cID, pa.cID)')->leftJoin('p', 'PageTypes', 'pt', 'pt.ptID = if(pa.cID is null, p.ptID, pa.ptID)')->leftJoin('p', 'CollectionSearchIndexAttributes', 'csi', 'csi.cID = if(pa.cID is null, p.cID, pa.cID)')->innerJoin('p', 'CollectionVersions', 'cv', 'cv.cID = if(pa.cID is null, p.cID, pa.cID)')->innerJoin('p', 'Collections', 'c', 'p.cID = c.cID')->andWhere('p.cIsTemplate = 0 or pa.cIsTemplate = 0');
     } else {
         $query->from('Pages', 'p')->leftJoin('p', 'PagePaths', 'pp', '(p.cID = pp.cID and pp.ppIsCanonical = true)')->leftJoin('p', 'PageSearchIndex', 'psi', 'p.cID = psi.cID')->leftJoin('p', 'PageTypes', 'pt', 'p.ptID = pt.ptID')->leftJoin('c', 'CollectionSearchIndexAttributes', 'csi', 'c.cID = csi.cID')->innerJoin('p', 'Collections', 'c', 'p.cID = c.cID')->innerJoin('p', 'CollectionVersions', 'cv', 'p.cID = cv.cID')->andWhere('p.cPointerID < 1')->andWhere('p.cIsTemplate = 0');
     }
     if ($this->pageVersionToRetrieve == self::PAGE_VERSION_RECENT) {
         $query->andWhere('cvID = (select max(cvID) from CollectionVersions where cID = cv.cID)');
     } else {
         $query->andWhere('cvIsApproved = 1');
     }
     if ($this->isFulltextSearch) {
         $query->addSelect('match(psi.cName, psi.cDescription, psi.content) against (:fulltext) as cIndexScore');
     }
     if (!$this->includeInactivePages) {
         $query->andWhere('p.cIsActive = :cIsActive');
         $query->setParameter('cIsActive', true);
     }
     if (!$this->includeSystemPages) {
         $query->andWhere('p.cIsSystemPage = :cIsSystemPage');
         $query->setParameter('cIsSystemPage', false);
     }
     return $query;
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:25,代码来源:PageList.php

示例3: from

 /**
  * {@inheritdoc}
  * @return NativeQueryBuilder
  */
 public function from($from, $alias = NULL)
 {
     return parent::from($this->addTableResultMapping($from, $alias), $alias);
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:8,代码来源:NativeQueryBuilder.php

示例4: _loadResult

 /**
  * 加载数据库结果集
  *
  * @param  bool $multiple 是否加载多行数据
  * @return $this|mixed
  */
 protected function _loadResult($multiple = false)
 {
     $this->_dbBuilder->from($this->db()->quoteIdentifier($this->_tableName), $this->db()->quoteIdentifier($this->_objectName));
     // 只获取单条记录
     if (false === $multiple) {
         $this->_dbBuilder->setMaxResults(1);
     }
     // 默认选择所有字段
     $this->_dbBuilder->addSelect($this->_buildSelect());
     // 处理排序问题
     if (!isset($this->_dbApplied['orderBy']) && !empty($this->_sorting)) {
         foreach ($this->_sorting as $column => $direction) {
             if (false === strpos($column, '.')) {
                 // Sorting column for use in JOINs
                 $column = $this->_objectName . '.' . $column;
             }
             $this->_dbBuilder->orderBy($column, $direction);
         }
     }
     if (true === $multiple) {
         $result = $this->_dbBuilder->execute();
         $result->setFetchMode(PDO::FETCH_CLASS, $this->_loadMultiResultFetcherClass(), $this->_loadMultiResultFetcherConstructor());
         $this->reset();
         return $result->fetchAll();
     } else {
         $result = $this->_dbBuilder->execute()->fetch();
         $this->reset();
         if ($result) {
             $this->_loadValues($result);
         } else {
             $this->clear();
         }
         return $this;
     }
 }
开发者ID:tourze,项目名称:model,代码行数:41,代码来源:Model.php

示例5: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     if ($this->includeAliases) {
         $query->from('Pages', 'p')->leftJoin('p', 'Pages', 'pa', 'p.cPointerID = pa.cID')->leftJoin('p', 'PagePaths', 'pp', 'p.cID = pp.cID and pp.ppIsCanonical = true')->leftJoin('pa', 'PageSearchIndex', 'psi', 'psi.cID = if(pa.cID is null, p.cID, pa.cID)')->leftJoin('p', 'PageTypes', 'pt', 'pt.ptID = if(pa.cID is null, p.ptID, pa.ptID)')->leftJoin('p', 'CollectionSearchIndexAttributes', 'csi', 'csi.cID = if(pa.cID is null, p.cID, pa.cID)')->innerJoin('p', 'CollectionVersions', 'cv', 'cv.cID = if(pa.cID is null, p.cID, pa.cID)')->innerJoin('p', 'Collections', 'c', 'p.cID = c.cID')->andWhere('p.cIsTemplate = 0 or pa.cIsTemplate = 0');
     } else {
         $query->from('Pages', 'p')->leftJoin('p', 'PagePaths', 'pp', '(p.cID = pp.cID and pp.ppIsCanonical = true)')->leftJoin('p', 'PageSearchIndex', 'psi', 'p.cID = psi.cID')->leftJoin('p', 'PageTypes', 'pt', 'p.ptID = pt.ptID')->leftJoin('c', 'CollectionSearchIndexAttributes', 'csi', 'c.cID = csi.cID')->innerJoin('p', 'Collections', 'c', 'p.cID = c.cID')->innerJoin('p', 'CollectionVersions', 'cv', 'p.cID = cv.cID')->andWhere('p.cPointerID < 1')->andWhere('p.cIsTemplate = 0');
     }
     switch ($this->pageVersionToRetrieve) {
         case self::PAGE_VERSION_RECENT:
             $query->andWhere('cvID = (select max(cvID) from CollectionVersions where cID = cv.cID)');
             break;
         case self::PAGE_VERSION_RECENT_UNAPPROVED:
             $query->andWhere('cvID = (select max(cvID) from CollectionVersions where cID = cv.cID)')->andWhere('cvIsApproved = 0');
             break;
         case self::PAGE_VERSION_ACTIVE:
         default:
             $query->andWhere('cvIsApproved = 1');
             break;
     }
     if ($this->isFulltextSearch) {
         $query->addSelect('match(psi.cName, psi.cDescription, psi.content) against (:fulltext) as cIndexScore');
     }
     if (!$this->includeInactivePages) {
         $query->andWhere('p.cIsActive = :cIsActive');
         $query->setParameter('cIsActive', true);
     }
     if (is_object($this->siteTree)) {
         $tree = $this->siteTree;
     } else {
         $site = \Core::make("site")->getSite();
         $tree = $site->getSiteTreeObject();
     }
     // Note, we might not use this. We have to set the parameter even if we don't use it because
     // StackList (which extends PageList) needs to have it available.
     $query->setParameter('siteTreeID', $tree->getSiteTreeID());
     if ($this->query->getParameter('cParentID') < 1) {
         if (!$this->includeSystemPages) {
             $query->andWhere('p.siteTreeID = :siteTreeID');
             $query->andWhere('p.cIsSystemPage = :cIsSystemPage');
             $query->setParameter('cIsSystemPage', false);
         } else {
             $query->andWhere('(p.siteTreeID = :siteTreeID or p.siteTreeID = 0)');
         }
     }
     return $query;
 }
开发者ID:seebaermichi,项目名称:concrete5,代码行数:46,代码来源:PageList.php

示例6: fromQuotesIdentifierAndDelegatesToConcreteQueryBuilder

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

示例7: from

 /**
  * Creates and adds a query root corresponding to the table identified by the
  * given alias, forming a cartesian product with any existing query roots.
  *
  * <code>
  *     $qb = $conn->getQueryBuilder()
  *         ->select('u.id')
  *         ->from('users', 'u')
  * </code>
  *
  * @param string $from The table.
  * @param string|null $alias The alias of the table.
  *
  * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
  */
 public function from($from, $alias = null)
 {
     $this->queryBuilder->from($this->getTableName($from), $alias);
     return $this;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:20,代码来源:QueryBuilder.php

示例8: from

 /**
  * Creates and adds a query root corresponding to the table identified by the
  * given alias, forming a cartesian product with any existing query roots.
  *
  * @param string $from  The table.
  * @param string $alias The alias of the table.
  *
  * @return self
  */
 public function from($from, $alias)
 {
     $this->qb->from($from, $alias);
     return $this;
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:SqlQueryBuilder.php

示例9: from

 /**
  * Creates and adds a query root corresponding to the table identified by the
  * given alias, forming a cartesian product with any existing query roots.
  *
  * <code>
  *     $qb = $conn->getQueryBuilder()
  *         ->select('u.id')
  *         ->from('users', 'u')
  * </code>
  *
  * @param string $from The table.
  * @param string|null $alias The alias of the table.
  *
  * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
  */
 public function from($from, $alias = null)
 {
     $this->queryBuilder->from($this->helper->quoteColumnName($from), $alias);
     return $this;
 }
开发者ID:henkRW,项目名称:core,代码行数:20,代码来源:querybuilder.php


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