1
0
mirror of synced 2025-01-19 06:51:40 +03:00

little sequence handling fix

This commit is contained in:
zYne 2007-01-29 20:10:51 +00:00
parent 360c8ea207
commit 4319d095f6
7 changed files with 30 additions and 29 deletions

View File

@ -32,9 +32,9 @@
*/
class Doctrine_Cache
{
protected $_options = array('size' => 1000,
'lifetime' => 3600,
);
protected $_options = array('size' => 1000,
'lifetime' => 3600,
);
protected $_queries = array();
@ -45,7 +45,7 @@ class Doctrine_Cache
* @param string $query sql query string
* @return void
*/
public function process($query)
public function addQuery($query)
{
$this->queries[] = $query;
}
@ -54,7 +54,7 @@ class Doctrine_Cache
*
* @return boolean
*/
public function save()
public function processAll()
{
$content = file_get_contents($this->_statsFile);
$queries = explode("\n", $content);

View File

@ -97,6 +97,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
),
'wildcards' => array('%', '_')
);
/**
* @var array $serverInfo
*/
protected $serverInfo = array();
/**
* @var array $availibleDrivers an array containing all availible drivers
*/

View File

@ -145,15 +145,15 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
* @return mixed array/string with version information or MDB2 error object
*/
public function getServerVersion($native = false)
{
if ($this->connected_server_info) {
$serverInfo = $this->connected_server_info;
{
if ($this->serverInfo) {
$serverInfo = $this->serverInfo;
} else {
$query = 'SELECT @@VERSION';
$serverInfo = $this->fetchOne($query);
}
// cache server_info
$this->connected_server_info = $serverInfo;
$this->serverInfo = $serverInfo;
if ( ! $native) {
if (preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $serverInfo, $tmp)) {
$serverInfo = array(

View File

@ -47,7 +47,7 @@ class Doctrine_Sequence_Firebird extends Doctrine_Sequence
$query = 'SELECT GEN_ID(' . $sequenceName . ', 1) as the_value FROM RDB$DATABASE';
try {
$result = $this->queryOne($query, 'integer');
$result = $this->conn->fetchOne($query, 'integer');
} catch(Doctrine_Connection_Exception $e) {
if ($onDemand && $e->getPortableCode() == Doctrine::ERR_NOSUCHTABLE) {
@ -75,9 +75,9 @@ class Doctrine_Sequence_Firebird extends Doctrine_Sequence
* @param string name of the table into which a new row was inserted
* @param string name of the field into which a new row was inserted
*/
public function lastInsertID($table = null, $field = null)
public function lastInsertId($table = null, $field = null)
{
throw new Doctrine_Sequence_Exception('method not implemented');
return $this->conn->getDbh()->lastInsertId();
}
/**
* Returns the current id of a sequence
@ -86,14 +86,14 @@ class Doctrine_Sequence_Firebird extends Doctrine_Sequence
*
* @return integer current id in the given sequence
*/
public function currID($seqName)
public function currId($seqName)
{
$sequenceName = $this->conn->quoteIdentifier($this->getSequenceName($seqName), true);
$query = 'SELECT GEN_ID(' . $sequenceName . ', 0) as the_value FROM RDB$DATABASE';
try {
$value = $this->queryOne($query);
$value = $this->conn->fetchOne($query);
} catch(Doctrine_Connection_Exception $e) {
throw new Doctrine_Sequence_Exception('Unable to select from ' . $seqName);
}

View File

@ -40,7 +40,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
*
* @return integer next id in the given sequence
*/
public function nextID($seqName, $ondemand = true)
public function nextId($seqName, $ondemand = true)
{
$sequenceName = $this->conn->quoteIdentifier($this->getSequenceName($seqName), true);
$seqcolName = $this->conn->quoteIdentifier($this->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true);
@ -71,7 +71,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
}
}
$value = $this->lastInsertID($sequenceName);
$value = $this->lastInsertId($sequenceName);
if (is_numeric($value)) {
$query = 'DELETE FROM ' . $sequenceName . ' WHERE ' . $seqcolName . ' < ' . $value;
@ -92,9 +92,9 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
* @param string name of the table into which a new row was inserted
* @param string name of the field into which a new row was inserted
*/
public function lastInsertID($table = null, $field = null)
public function lastInsertId($table = null, $field = null)
{
$serverInfo = $this->getServerVersion();
$serverInfo = $this->conn->getServerVersion();
if (is_array($serverInfo)
&& ! is_null($serverInfo['major'])
&& $serverInfo['major'] >= 8) {
@ -105,7 +105,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
$query = 'SELECT @@IDENTITY';
}
return $this->fetchOne($query);
return $this->conn->fetchOne($query);
}
/**
* Returns the current id of a sequence
@ -114,10 +114,10 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
*
* @return integer current id in the given sequence
*/
public function currID($seqName)
public function currId($seqName)
{
$this->warnings[] = 'database does not support getting current
sequence value, the sequence value was incremented';
return $this->nextID($seqName);
return $this->nextId($seqName);
}
}

View File

@ -90,7 +90,7 @@ class Doctrine_Sequence_Sqlite extends Doctrine_Sequence
*/
public function lastInsertId($table = null, $field = null)
{
return $this->conn->getDbh()->lastInsertID();
return $this->conn->getDbh()->lastInsertId();
}
/**
* Returns the current id of a sequence

View File

@ -1,7 +1,7 @@
<?php
ob_start();
ini_set('max_execution_time',900);
ini_set('max_execution_time', 900);
function autoload($class) {
if(strpos($class, 'TestCase') === false)
@ -135,7 +135,6 @@ $test->addTestCase(new Doctrine_Expression_Pgsql_TestCase());
$test->addTestCase(new Doctrine_Expression_Oracle_TestCase());
$test->addTestCase(new Doctrine_Expression_Sqlite_TestCase());
// Core
$test->addTestCase(new Doctrine_Access_TestCase());
@ -197,14 +196,11 @@ $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
$test->addTestCase(new Doctrine_Query_ReferenceModel_TestCase());
$test->addTestCase(new Doctrine_Query_Condition_TestCase());
$test->addTestCase(new Doctrine_Query_ComponentAlias_TestCase());
$test->addTestCase(new Doctrine_Query_Subquery_TestCase());
$test->addTestCase(new Doctrine_Query_TestCase());
$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase());
$test->addTestCase(new Doctrine_Query_Delete_TestCase());
$test->addTestCase(new Doctrine_Query_Where_TestCase());
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
$test->addTestCase(new Doctrine_Query_IdentifierQuoting_TestCase());
$test->addTestCase(new Doctrine_Query_Update_TestCase());
@ -219,8 +215,9 @@ $test->addTestCase(new Doctrine_Query_JoinCondition_TestCase());
$test->addTestCase(new Doctrine_ColumnAlias_TestCase());
$test->addTestCase(new Doctrine_Query_Subquery_TestCase());
$test->addTestCase(new Doctrine_Query_Orderby_TestCase());
// Cache tests