當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。