Changeset 4452 for trunk/lib/Doctrine
- Timestamp:
- 05/27/08 05:52:50 (8 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 8 modified
-
EntityManager.php (modified) (1 diff)
-
Query.php (modified) (9 diffs)
-
Query/Parser.php (modified) (1 diff)
-
Query/ParserResult.php (modified) (1 diff)
-
Query/Production/DeleteStatement.php (modified) (1 diff)
-
Query/Production/UpdateStatement.php (modified) (1 diff)
-
Query/Production/WhereClause.php (modified) (1 diff)
-
Query/SqlBuilder.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/EntityManager.php
r4436 r4452 247 247 $query = new Doctrine_Query($this); 248 248 if ( ! empty($dql)) { 249 $query-> parseQuery($dql);249 $query->setDql($dql); 250 250 } 251 251 -
trunk/lib/Doctrine/Query.php
r4422 r4452 38 38 { 39 39 /** 40 * @var Doctrine_ Connection The connectionused by this query object.41 */ 42 protected $_ connection;40 * @var Doctrine_EntityManager The entity manager used by this query object. 41 */ 42 protected $_entityManager; 43 43 44 44 /** … … 94 94 95 95 96 public function __construct(Doctrine_Connection $conn = null, Doctrine_Hydrator_Abstract $hydrator = null) 97 { 98 $this->setConnection($conn); 99 100 if ($hydrator === null) { 101 $hydrator = new Doctrine_Hydrator(Doctrine_EntityManager::getManager()); 102 } 103 104 $this->_hydrator = $hydrator; 96 public function __construct(Doctrine_EntityManager $entityManager) 97 { 98 $this->_entityManager = $entityManager; 99 $this->_hydrator = new Doctrine_Hydrator($entityManager); 105 100 106 101 $this->free(); … … 121 116 122 117 /** 123 * Retrieves the assocated Doctrine_Connection to this Doctrine_Query 124 * 125 * @return Doctrine_Connection 126 */ 127 public function getConnection() 128 { 129 return $this->_connection; 130 } 131 132 133 /** 134 * Defines an assocated Doctrine_Connection to this Doctrine_Query 135 * 136 * @param Doctrine_Connection $conn A valid Doctrine_Connection 137 * @return void 138 */ 139 public function setConnection(Doctrine_Connection $conn = null) 140 { 141 if ($conn === null) { 142 $conn = Doctrine_EntityManager::getManager()->getConnection(); 143 } 144 145 $this->_connection = $conn; 118 * Retrieves the assocated Doctrine_EntityManager to this Doctrine_Query 119 * 120 * @return Doctrine_EntityManager 121 */ 122 public function getEntityManager() 123 { 124 return $this->_entityManager; 146 125 } 147 126 … … 231 210 { 232 211 if ($this->_state === self::STATE_DIRTY) { 233 $parser = new Doctrine_Query_Parser($this ->getDql());212 $parser = new Doctrine_Query_Parser($this); 234 213 $this->_parserResult = $parser->parse(); 235 214 $this->_state = self::STATE_CLEAN; … … 314 293 { 315 294 // If there is a CacheDriver associated to cache queries... 316 if ($this->_queryCache || $this->_ connection->getAttribute(Doctrine::ATTR_QUERY_CACHE)) {295 if ($this->_queryCache || $this->_entityManager->getConnection()->getAttribute(Doctrine::ATTR_QUERY_CACHE)) { 317 296 $queryCacheDriver = $this->getQueryCacheDriver(); 318 297 … … 348 327 // We always have an instance of Doctrine_Query_ParserResult on hands... 349 328 if ($this->_parserResult->isLimitSubqueryUsed() && 350 $this->_ connection->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {329 $this->_entityManager->getConnection()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') { 351 330 $params = array_merge($params, $params); 352 331 } … … 363 342 { 364 343 // Convert boolean params 365 $params = $this->_ connection->convertBooleans($params);344 $params = $this->_entityManager->getConnection()->convertBooleans($params); 366 345 367 346 // Convert enum params … … 400 379 return $this->_resultCache; 401 380 } else { 402 return $this->_ connection->getResultCacheDriver();381 return $this->_entityManager->getConnection()->getResultCacheDriver(); 403 382 } 404 383 } … … 489 468 return $this->_queryCache; 490 469 } else { 491 return $this->_ connection->getQueryCacheDriver();470 return $this->_entityManager->getConnection()->getQueryCacheDriver(); 492 471 } 493 472 } -
trunk/lib/Doctrine/Query/Parser.php
r4451 r4452 112 112 * @param Doctrine_Connection $connection The connection to use 113 113 */ 114 public function __construct( $dql, Doctrine_Connection $connection = null)115 { 116 $this->_scanner = new Doctrine_Query_Scanner($ dql);117 $this->_sqlBuilder = Doctrine_Query_SqlBuilder::fromConnection($ connection);114 public function __construct(Doctrine_Query $query) 115 { 116 $this->_scanner = new Doctrine_Query_Scanner($query->getDql()); 117 $this->_sqlBuilder = Doctrine_Query_SqlBuilder::fromConnection($query->getEntityManager()); 118 118 $this->_keywordTable = new Doctrine_Query_Token(); 119 119 -
trunk/lib/Doctrine/Query/ParserResult.php
r4451 r4452 75 75 * @param array $queryFields Query fields. 76 76 */ 77 public function setQuery Components(array $queryFields)77 public function setQueryFields(array $queryFields) 78 78 { 79 79 $this->_queryFields = $queryFields; -
trunk/lib/Doctrine/Query/Production/DeleteStatement.php
r4422 r4452 55 55 // Simple "DELETE FROM table_name" gives 0 affected rows. 56 56 return $this->_deleteClause->buildSql() . (($this->_whereClause !== null) 57 ? $this->_whereClause->buildSql() : ' WHERE 1 = 1');57 ? ' ' . $this->_whereClause->buildSql() : ' WHERE 1 = 1'); 58 58 } 59 59 } -
trunk/lib/Doctrine/Query/Production/UpdateStatement.php
r4422 r4452 55 55 // Simple "UPDATE table_name SET column_name = value" gives 0 affected rows. 56 56 return $this->_updateClause->buildSql() . (($this->_whereClause !== null) 57 ? $this->_whereClause->buildSql() : ' WHERE 1 = 1');57 ? ' ' . $this->_whereClause->buildSql() : ' WHERE 1 = 1'); 58 58 } 59 59 } -
trunk/lib/Doctrine/Query/Production/WhereClause.php
r4422 r4452 48 48 public function buildSql() 49 49 { 50 return ' WHERE ' . $this->_conditionalExpression->buildSql();50 return 'WHERE ' . $this->_conditionalExpression->buildSql(); 51 51 } 52 52 } -
trunk/lib/Doctrine/Query/SqlBuilder.php
r4422 r4452 43 43 44 44 45 public static function fromConnection(Doctrine_ Connection $connection = null)45 public static function fromConnection(Doctrine_EntityManager $entityManager) 46 46 { 47 if ($connection === null) { 48 $connection = Doctrine_EntityManager::getManager()->getConnection(); 49 } 47 $connection = $entityManager->getConnection(); 50 48 51 49 $className = "Doctrine_Query_SqlBuilder_" . $connection->getDriverName();