diff --git a/Doctrine/Cache/Query/Sqlite.php b/Doctrine/Cache/Query/Sqlite.php index db0c9c398..f51ca09b1 100644 --- a/Doctrine/Cache/Query/Sqlite.php +++ b/Doctrine/Cache/Query/Sqlite.php @@ -14,15 +14,15 @@ class Doctrine_Cache_Query_Sqlite implements Countable { private $dbh; /** * constructor - * - * Doctrine_Table $table + * + * @param Doctrine_Connection|null $connection */ - public function __construct(Doctrine_Session $session) { - $this->session = $session; - $dir = $session->getAttribute(Doctrine::ATTR_CACHE_DIR); + public function __construct($connection = null) { + if( ! ($connection instanceof Doctrine_Session)) + $connection = Doctrine_Manager::getInstance()->getCurrentConnection(); - if( ! is_dir($dir)) - mkdir($dir, 0777); + $this->session = $connection; + $dir = $this->session->getAttribute(Doctrine::ATTR_CACHE_DIR); $this->path = $dir.DIRECTORY_SEPARATOR; $this->dbh = new PDO("sqlite::memory:"); @@ -83,6 +83,17 @@ class Doctrine_Cache_Query_Sqlite implements Countable { $stmt = $this->dbh->query($sql); return $stmt->rowCount(); } + /** + * deleteExpired + * returns the number of deleted rows + * + * @return integer + */ + public function deleteExpired() { + $sql = "DELETE FROM ".self::CACHE_TABLE." WHERE expired < ?"; + $stmt = $this->dbh->prepare($sql); + $stmt->execute(array(time())); + } /** * delete * returns whether or not the given diff --git a/Doctrine/Hydrate.php b/Doctrine/Hydrate.php index 86165381d..43a0413b0 100644 --- a/Doctrine/Hydrate.php +++ b/Doctrine/Hydrate.php @@ -278,7 +278,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { if($this->isLimitSubqueryUsed()) $params = array_merge($params, $params); - + $stmt = $this->session->execute($query,$params); $previd = array(); diff --git a/Doctrine/Query.php b/Doctrine/Query.php index e0d3e6a7f..29b3d940e 100644 --- a/Doctrine/Query.php +++ b/Doctrine/Query.php @@ -250,7 +250,7 @@ class Doctrine_Query extends Doctrine_Hydrate { * @return boolean */ public function isLimitSubqueryUsed() { - return true; + return $this->limitSubqueryUsed; } /** * returns the built sql query diff --git a/tests/ViewTestCase.php b/tests/ViewTestCase.php index c88a3a22c..a45f1e9f0 100644 --- a/tests/ViewTestCase.php +++ b/tests/ViewTestCase.php @@ -35,8 +35,9 @@ class Doctrine_ViewTestCase extends Doctrine_UnitTestCase { $success = false; } $this->assertTrue($success); - - } + public function testConstructor() { + + } } ?> diff --git a/tests/run.php b/tests/run.php index 3eaefdf19..509e4bb02 100644 --- a/tests/run.php +++ b/tests/run.php @@ -28,7 +28,7 @@ require_once("QueryLimitTestCase.php"); error_reporting(E_ALL); $test = new GroupTest("Doctrine Framework Unit Tests"); -/** + $test->addTestCase(new Doctrine_RecordTestCase()); $test->addTestCase(new Doctrine_SessionTestCase()); @@ -64,10 +64,10 @@ $test->addTestCase(new Doctrine_ValidatorTestCase()); $test->addTestCase(new Doctrine_CollectionTestCase()); $test->addTestCase(new Doctrine_QueryTestCase()); -*/ + $test->addTestCase(new Doctrine_Query_Limit_TestCase()); -//$test->addTestCase(new Doctrine_RawSql_TestCase()); +$test->addTestCase(new Doctrine_RawSql_TestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());