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


PHP QueryBuilder::getSQL方法代码示例

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


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

示例1: getSQLDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function getSQLDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->getSQL()->shouldBeCalled()->willReturn('UPDATE aTable SET pid = 7');
     $this->concreteQueryBuilder->getType()->willReturn(2);
     // Update Type
     $this->subject->getSQL();
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:10,代码来源:QueryBuilderTest.php

示例2: logBuilder

 /**
  * @param QueryBuilder $builder
  */
 public static function logBuilder($builder)
 {
     $sql = $builder->getSQL();
     $params = $builder->getParameters();
     self::log("Running Query: " . $sql . " with params:");
     self::logObject($params);
 }
开发者ID:matheusviegas,项目名称:crudkit,代码行数:10,代码来源:LoggingHelper.php

示例3: addQueryFromBuilder

 /**
  * Add a query from a query builder
  *
  * @param QueryBuilder $qb
  * @return $this
  */
 public function addQueryFromBuilder(QueryBuilder $qb)
 {
     /**
      * @TODO : How to manage query params ?
      */
     $this->queries[] = new Query($qb->getSQL());
     return $this;
 }
开发者ID:itkg,项目名称:core,代码行数:14,代码来源:Loader.php

示例4: getNextAlias

 /**
  * @param   QueryBuilder  $query  The query builder
  *
  * @return  string
  */
 private function getNextAlias($query)
 {
     if (!preg_match_all('~\\b(\\w+)\\.~', $query->getSQL(), $matches)) {
         return 'b';
     }
     $aliases = array_unique($matches[1]);
     for ($alias = 'b'; in_array($alias, $aliases); $alias++) {
         continue;
     }
     return $alias;
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:16,代码来源:QueryDatabaseListener.php

示例5: getSQL

 /**
  * {@inheritdoc}
  */
 public function getSQL()
 {
     return $this->qb->getSQL();
 }
开发者ID:antrampa,项目名称:platform,代码行数:7,代码来源:SqlQuery.php

示例6: current

 public function current()
 {
     return $this->dbal->fetchAll($this->qb->getSQL());
 }
开发者ID:stopsopa,项目名称:elastic,代码行数:4,代码来源:AbstractDbalProvider.php

示例7: createQuery

 /**
  * @param QueryBuilder $qb
  *
  * @return NativeQuery
  */
 private function createQuery(QueryBuilder $qb)
 {
     $query = $this->em->createNativeQuery($qb->getSQL(), $this->rsm);
     $query->setParameters($this->qb->getParameters());
     return $query;
 }
开发者ID:kbond,项目名称:porpaginas,代码行数:11,代码来源:RSMQueryResult.php

示例8: testGetState

 public function testGetState()
 {
     $qb = new QueryBuilder($this->conn);
     $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
     $qb->select('u.*')->from('users', 'u');
     $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
     $sql1 = $qb->getSQL();
     $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
     $this->assertEquals($sql1, $qb->getSQL());
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:10,代码来源:QueryBuilderTest.php

示例9: testSelectFromMasterWithWhereOnJoinedTables

 /**
  * @group DBAL-172
  */
 public function testSelectFromMasterWithWhereOnJoinedTables()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('COUNT(DISTINCT news.id)')->from('newspages', 'news')->innerJoin('news', 'nodeversion', 'nv', "nv.refId = news.id AND nv.refEntityname='Entity\\News'")->innerJoin('nv', 'nodetranslation', 'nt', 'nv.nodetranslation = nt.id')->innerJoin('nt', 'node', 'n', 'nt.node = n.id')->where('nt.lang = ?')->andWhere('n.deleted = 0');
     $this->assertEquals("SELECT COUNT(DISTINCT news.id) FROM newspages news INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)", $qb->getSQL());
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:9,代码来源:QueryBuilderTest.php

示例10: testJoinWithNonUniqueAliasThrowsException

 /**
  * @group DBAL-1137
  */
 public function testJoinWithNonUniqueAliasThrowsException()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('a.id')->from('table_a', 'a')->join('a', 'table_b', 'a', 'a.fk_b = a.id');
     $this->setExpectedException('Doctrine\\DBAL\\Query\\QueryException', "The given alias 'a' is not unique in FROM and JOIN clause table. The currently registered aliases are: a.");
     $qb->getSQL();
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:10,代码来源:QueryBuilderTest.php

示例11: getSQL

 /**
  * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
  *
  * <code>
  *     $qb = $conn->getQueryBuilder()
  *         ->select('u')
  *         ->from('User', 'u')
  *     echo $qb->getSQL(); // SELECT u FROM User u
  * </code>
  *
  * @return string The SQL query string.
  */
 public function getSQL()
 {
     return $this->queryBuilder->getSQL();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:16,代码来源:QueryBuilder.php

示例12: testReferenceJoinFromJoin

 /**
  * @group DBAL-172
  */
 public function testReferenceJoinFromJoin()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select("l.id", "mdsh.xcode", "mdso.xcode")->from("location_tree", "l")->join("l", "location_tree_pos", "p", "l.id = p.tree_id")->rightJoin("l", "hotel", "h", "h.location_id = l.id")->leftJoin("l", "offer_location", "ol", "l.id=ol.location_id")->leftJoin("ol", "mds_offer", "mdso", "ol.offer_id = mdso.offer_id")->leftJoin("h", "mds_hotel", "mdsh", "h.id = mdsh.hotel_id")->where("p.parent_id IN (:ids)")->andWhere("(mdso.xcode IS NOT NULL OR mdsh.xcode IS NOT NULL)");
     $this->setExpectedException('Doctrine\\DBAL\\Query\\QueryException', "The given alias 'ol' is not part of any FROM clause table. The currently registered FROM-clause aliases are: l");
     $this->assertEquals('', $qb->getSQL());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:10,代码来源:QueryBuilderTest.php

示例13: testSelectWithMultipleFromAndJoins

 /**
  * @group DBAL-442
  */
 public function testSelectWithMultipleFromAndJoins()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('DISTINCT u.id')->from('users', 'u')->from('articles', 'a')->innerJoin('u', 'permissions', 'p', 'p.user_id = u.id')->innerJoin('a', 'comments', 'c', 'c.article_id = a.id')->where('u.id = a.user_id')->andWhere('p.read = 1');
     $this->assertEquals('SELECT DISTINCT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles a INNER JOIN comments c ON c.article_id = a.id WHERE (u.id = a.user_id) AND (p.read = 1)', $qb->getSQL());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:9,代码来源:QueryBuilderTest.php

示例14: testComplexSelectWithSomeTableAliases

 public function testComplexSelectWithSomeTableAliases()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->select('u.id')->from('users', 'u')->from('articles')->innerJoin('u', 'permissions', 'p', 'p.user_id = u.id')->innerJoin('articles', 'comments', 'c', 'c.article_id = articles.id');
     $this->assertEquals('SELECT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles INNER JOIN comments c ON c.article_id = articles.id', $qb->getSQL());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:6,代码来源:QueryBuilderTest.php

示例15: formatQuery

 /**
  * Format SQL query by replacing {x} and {x.y} tokens.
  *
  * @staticvar string $re
  *
  * @param \Doctrine\DBAL\Query\QueryBuilder $qb
  * @param array                             $tables
  *
  * @throws \Lokhman\Silex\ARM\Exception\RepositoryException
  * @return string
  */
 private function formatQuery(QueryBuilder $qb, array $tables)
 {
     static $re = '/("|\').*?\\1(*SKIP)(*FAIL)|\\{(?:[^{}]|(?R))*\\}/';
     return preg_replace_callback($re, function ($matches) use($tables) {
         if (false !== ($pos = strpos($token = substr($matches[0], 1, -1), '.'))) {
             if (!isset($tables[$alias = substr($token, 0, $pos)])) {
                 self::raise('No repository registered for "' . $alias . '".');
             }
             return $tables[$alias]->getTable() . self::UNIQUE . substr($token, $pos + 1);
         } elseif (in_array($token, $this->metadata->getColumns())) {
             return $this->table . self::UNIQUE . $token;
         } else {
             return $matches[0];
         }
     }, $qb->getSQL());
 }
开发者ID:lokhman,项目名称:silex-arm,代码行数:27,代码来源:Repository.php


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