1
0
mirror of synced 2025-01-18 06:21:40 +03:00

little DQL LIMIT fix

This commit is contained in:
zYne 2006-08-21 21:04:20 +00:00
parent beda312f1c
commit bdce1d8d62
5 changed files with 26 additions and 14 deletions

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -35,8 +35,9 @@ class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
$success = false;
}
$this->assertTrue($success);
}
public function testConstructor() {
}
}
?>

View File

@ -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());