1
0
mirror of synced 2025-02-20 14:13:15 +03:00

Ability to pass null to rawSql / Query constructor, Doctrine uses then the current connection

This commit is contained in:
zYne 2006-08-21 19:48:24 +00:00
parent 392683e10d
commit f3c0a27d6b
4 changed files with 13 additions and 8 deletions

View File

@ -87,10 +87,13 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
/**
* constructor
*
* @param Doctrine_Session $session
* @param Doctrine_Connection|null $connection
*/
public function __construct(Doctrine_Session $session) {
$this->session = $session;
public function __construct($connection = null) {
if( ! ($connection instanceof Doctrine_Session))
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$this->session = $connection;
}
/**
* getQuery

View File

@ -470,7 +470,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
case "lazyoffset":
$fetchmode = Doctrine::FETCH_LAZYOFFSET;
default:
throw new DQLException("Unknown fetchmode '$mode'. The availible fetchmodes are 'i', 'b' and 'l'.");
throw new Doctrine_Query_Exception("Unknown fetchmode '$mode'. The availible fetchmodes are 'i', 'b' and 'l'.");
endswitch;
return $fetchmode;
}
@ -541,7 +541,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
*
* @param string $path the path of the loadable component
* @param integer $fetchmode optional fetchmode, if not set the components default fetchmode will be used
* @throws DQLException
* @throws Doctrine_Query_Exception
* @return Doctrine_Table
*/
final public function load($path, $loadFields = true) {
@ -655,7 +655,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
$prevPath = $currPath;
$prevTable = $tableName;
} catch(Exception $e) {
throw new DQLException($e->__toString());
throw new Doctrine_Query_Exception($e->__toString());
}
}
return $table;

View File

@ -97,7 +97,9 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this->assertEqual($this->query->getQuery(),
'SELECT entity.id AS entity__id, phonenumber.id AS phonenumber__id, phonenumber.phonenumber AS phonenumber__phonenumber, phonenumber.entity_id AS phonenumber__entity_id FROM entity INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE entity.id IN (SELECT DISTINCT entity.id FROM entity INNER JOIN phonenumber ON entity.id = phonenumber.entity_id WHERE (entity.type = 0) LIMIT 5 OFFSET 2) AND (entity.type = 0)');
}
public function testLimitWithPreparedQueries() {
}
public function testLimitWithManyToManyLeftJoin() {
$q = new Doctrine_Query($this->session);
$q->from("User.Group")->limit(5);

View File

@ -1126,7 +1126,7 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$users = $query->query("FROM User-unknown");
} catch(Exception $e) {
}
$this->assertTrue($e instanceof DQLException);
$this->assertTrue($e instanceof Doctrine_Query_Exception);
$users = $query->query("FROM User-i");