Firebird, mssql, mysql, oracle and pgsql connection drivers updated
This commit is contained in:
parent
87f9122f7d
commit
dcc59843a0
@ -24,8 +24,11 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 library)
|
||||
* @license LGPL
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @author Konsta Vesterinen
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 library interbase driver)
|
||||
* @version $Id$
|
||||
*/
|
||||
class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
/**
|
||||
@ -129,7 +132,6 @@ class Doctrine_Connection_Firebird extends Doctrine_Connection {
|
||||
* Set the charset on the current connection
|
||||
*
|
||||
* @param string charset
|
||||
* @param resource connection handle
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -24,7 +24,10 @@ Doctrine::autoload('Doctrine_Connection');
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @license LGPL
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @author Konsta Vesterinen
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
* @version $Id$
|
||||
*/
|
||||
class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
/**
|
||||
@ -39,16 +42,50 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
*/
|
||||
public function __construct(Doctrine_Manager $manager, PDO $pdo) {
|
||||
// initialize all driver options
|
||||
$this->supported = array(
|
||||
'sequences' => 'emulated',
|
||||
'indexes' => true,
|
||||
'affected_rows' => true,
|
||||
'transactions' => true,
|
||||
'summary_functions' => true,
|
||||
'order_by_text' => true,
|
||||
'current_id' => 'emulated',
|
||||
'limit_queries' => 'emulated',
|
||||
'LOBs' => true,
|
||||
'replace' => 'emulated',
|
||||
'sub_selects' => true,
|
||||
'auto_increment' => true,
|
||||
'primary_key' => true,
|
||||
'result_introspection' => true,
|
||||
'prepared_statements' => 'emulated',
|
||||
);
|
||||
|
||||
parent::__construct($manager, $pdo);
|
||||
}
|
||||
/**
|
||||
* quoteIdentifier
|
||||
* Quote a string so it can be safely used as a table / column name
|
||||
*
|
||||
* Quoting style depends on which database driver is being used.
|
||||
*
|
||||
* @param string $identifier identifier name to be quoted
|
||||
* @param bool $checkOption check the 'quote_identifier' option
|
||||
*
|
||||
* @return string quoted identifier string
|
||||
*/
|
||||
public function quoteIdentifier($identifier, $checkOption = false) {
|
||||
if ($check_option && ! $this->options['quote_identifier']) {
|
||||
return $identifier;
|
||||
}
|
||||
return '[' . str_replace(']', ']]', $identifier) . ']';
|
||||
}
|
||||
/**
|
||||
* returns the next value in the given sequence
|
||||
*
|
||||
* @param string $sequence name of the sequence
|
||||
* @return integer the next value in the given sequence
|
||||
*/
|
||||
public function getNextID($sequence) {
|
||||
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);
|
||||
@ -64,8 +101,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
|
||||
* @return string
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset) {
|
||||
if ($limit) {
|
||||
public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
|
||||
if($limit > 0) {
|
||||
|
||||
// we need the starting SELECT clause for later
|
||||
$select = 'SELECT ';
|
||||
@ -77,7 +114,7 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
// is there an offset?
|
||||
if (! $offset) {
|
||||
// no offset, it's a simple TOP count
|
||||
return "$select TOP $count" . substr($query, $length);
|
||||
return $select . ' TOP ' . $count . substr($query, $length);
|
||||
}
|
||||
|
||||
// the total of the count **and** the offset, combined.
|
||||
@ -108,5 +145,27 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
|
||||
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* Returns the autoincrement ID if supported or $id or fetches the current
|
||||
* ID in a sequence called: $table.(empty($field) ? '' : '_'.$field)
|
||||
*
|
||||
* @param string $table name of the table into which a new row was inserted
|
||||
* @param string $field name of the field into which a new row was inserted
|
||||
* @return mixed MDB2 Error Object or id
|
||||
* @access public
|
||||
*/
|
||||
function lastInsertID($table = null, $field = null)
|
||||
{
|
||||
$server_info = $this->getServerVersion();
|
||||
if (is_array($server_info)
|
||||
&& !is_null($server_info['major'])
|
||||
&& $server_info['major'] >= 8) {
|
||||
$query = "SELECT SCOPE_IDENTITY()";
|
||||
} else {
|
||||
$query = "SELECT @@IDENTITY";
|
||||
}
|
||||
|
||||
return $this->queryOne($query, 'integer');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,10 @@ Doctrine::autoload('Doctrine_Connection_Common');
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @license LGPL
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @author Konsta Vesterinen
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
* @version $Id$
|
||||
*/
|
||||
class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
|
||||
/**
|
||||
|
@ -115,14 +115,15 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
|
||||
* @return void
|
||||
*/
|
||||
public function setTransactionIsolation($isolation) {
|
||||
switch ($isolation) {
|
||||
switch($isolation) {
|
||||
case 'READ UNCOMMITTED':
|
||||
$isolation = 'READ COMMITTED';
|
||||
break;
|
||||
case 'READ COMMITTED':
|
||||
case 'REPEATABLE READ':
|
||||
$isolation = 'SERIALIZABLE';
|
||||
case 'SERIALIZABLE':
|
||||
break;
|
||||
$isolation = 'SERIALIZABLE';
|
||||
break;
|
||||
default:
|
||||
throw new Doctrine_Connection_Oracle_Exception('Isolation level ' . $isolation . ' is not supported.');
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ Doctrine::autoload("Doctrine_Connection_Common");
|
||||
*
|
||||
* @package Doctrine ORM
|
||||
* @url www.phpdoctrine.com
|
||||
* @license LGPL
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @author Konsta Vesterinen
|
||||
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
||||
* @version $Id$
|
||||
*/
|
||||
class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
/**
|
||||
@ -59,7 +62,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
'identifier_quoting' => true,
|
||||
'pattern_escaping' => true,
|
||||
);
|
||||
|
||||
|
||||
$this->options['multi_query'] = false;
|
||||
|
||||
parent::__construct($manager, $pdo);
|
||||
|
Loading…
Reference in New Issue
Block a user