- make more use of Doctrine internal methods
This commit is contained in:
parent
d4750eef1d
commit
eae259a247
@ -87,7 +87,7 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
$this->exec($query);
|
||||
}
|
||||
/**
|
||||
* Adds an driver-specific LIMIT clause to the query
|
||||
@ -110,10 +110,8 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection
|
||||
* @param string $sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function getNextID($sequence)
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$stmt = $this->query('SELECT UNIQUE FROM ' . $sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetchOne('SELECT UNIQUE FROM ' . $sequence);
|
||||
}
|
||||
}
|
||||
|
@ -92,10 +92,17 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
|
||||
*/
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$this->query("INSERT INTO $sequence (vapor) VALUES (0)");
|
||||
$stmt = $this->query("SELECT @@IDENTITY FROM $sequence");
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
|
||||
$seqcolName = $this->quoteIdentifier($this->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true);
|
||||
$query = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (0)';
|
||||
$result = $this->exec($query);
|
||||
$value = $this->dbh->lastInsertId();
|
||||
|
||||
if (is_numeric($value)) {
|
||||
$query = 'DELETE FROM ' . $sequenceName . ' WHERE ' . $seqcolName . ' < ' . $value;
|
||||
$result = $this->exec($query);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
/**
|
||||
* Adds an adapter-specific LIMIT clause to the SELECT statement.
|
||||
@ -170,6 +177,6 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
|
||||
$query = "SELECT @@IDENTITY";
|
||||
}
|
||||
|
||||
return $this->queryOne($query);
|
||||
return $this->fetchOne($query);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
$this->exec($query);
|
||||
}
|
||||
/**
|
||||
* Returns the next free id of a sequence
|
||||
@ -118,12 +118,12 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
|
||||
$sequenceName = $this->quoteIdentifier($this->getSequenceName($seqName), true);
|
||||
$seqcolName = $this->quoteIdentifier($this->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true);
|
||||
$query = 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES (NULL)';
|
||||
|
||||
$result = $this->exec($query);
|
||||
$value = $this->dbh->lastInsertId();
|
||||
|
||||
if (is_numeric($value)) {
|
||||
$query = 'DELETE FROM ' . $sequenceName . ' WHERE ' . $seqcolName . ' < ' . $value;
|
||||
$result = $this->dbh->query($query);
|
||||
$result = $this->exec($query);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
@ -242,6 +242,6 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
|
||||
}
|
||||
$query = 'REPLACE INTO ' . $table . ' (' . $query . ') VALUES (' . $values . ')';
|
||||
|
||||
return $this->dbh->exec($query);
|
||||
return $this->exec($query);
|
||||
}
|
||||
}
|
||||
|
@ -112,9 +112,7 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection
|
||||
*/
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$stmt = $this->query('SELECT ' . $sequence . '.nextval FROM dual');
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetchOne('SELECT ' . $sequence . '.nextval FROM dual');
|
||||
}
|
||||
/**
|
||||
* Returns the current id of a sequence
|
||||
@ -126,8 +124,6 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection
|
||||
public function currId($sequence)
|
||||
{
|
||||
$sequence = $this->quoteIdentifier($this->getSequenceName($sequence), true);
|
||||
$stmt = $this->query('SELECT ' . $sequence . '.currval FROM dual');
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetchOne('SELECT ' . $sequence . '.currval FROM dual');
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
$this->exec($query);
|
||||
}
|
||||
/**
|
||||
* returns the next value in the given sequence
|
||||
@ -96,9 +96,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
|
||||
*/
|
||||
public function nextId($sequence)
|
||||
{
|
||||
$stmt = $this->dbh->query("SELECT NEXTVAL('$sequence')");
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetchOne("SELECT NEXTVAL('$sequence')");
|
||||
}
|
||||
/**
|
||||
* Returns the current id of a sequence
|
||||
@ -108,9 +106,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common
|
||||
*/
|
||||
public function currId($sequence)
|
||||
{
|
||||
$stmt = $this->dbh->query('SELECT last_value FROM '.$sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetcOne('SELECT last_value FROM '.$sequence);
|
||||
}
|
||||
/**
|
||||
* Changes a query string for various DBMS specific reasons
|
||||
|
@ -67,7 +67,7 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
|
||||
'pattern_escaping' => false,
|
||||
);
|
||||
/**
|
||||
$this->options['base_transaction_name'] = '___php_MDB2_sqlite_auto_commit_off';
|
||||
$this->options['base_transaction_name'] = '___php_Doctrine_sqlite_auto_commit_off';
|
||||
$this->options['fixed_float'] = 0;
|
||||
$this->options['database_path'] = '';
|
||||
$this->options['database_extension'] = '';
|
||||
@ -95,8 +95,6 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
|
||||
{
|
||||
$sequence = $this->quoteIdentifier($sequence, true);
|
||||
$seqColumn = $this->quoteIdentifier($this->options['seqcol_name'], true);
|
||||
$stmt = $this->dbh->query('SELECT MAX(' . $seqColumn . ') FROM ' . $sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
return $this->fetchOne('SELECT MAX(' . $seqColumn . ') FROM ' . $sequence);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user