Commit dcc59843 authored by zYne's avatar zYne

Firebird, mssql, mysql, oracle and pgsql connection drivers updated

parent 87f9122f
...@@ -24,8 +24,11 @@ Doctrine::autoload('Doctrine_Connection'); ...@@ -24,8 +24,11 @@ Doctrine::autoload('Doctrine_Connection');
* *
* @package Doctrine ORM * @package Doctrine ORM
* @url www.phpdoctrine.com * @url www.phpdoctrine.com
* @author Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 library) * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license 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 { class Doctrine_Connection_Firebird extends Doctrine_Connection {
/** /**
...@@ -129,7 +132,6 @@ 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 * Set the charset on the current connection
* *
* @param string charset * @param string charset
* @param resource connection handle
* *
* @return void * @return void
*/ */
......
...@@ -24,7 +24,10 @@ Doctrine::autoload('Doctrine_Connection'); ...@@ -24,7 +24,10 @@ Doctrine::autoload('Doctrine_Connection');
* *
* @package Doctrine ORM * @package Doctrine ORM
* @url www.phpdoctrine.com * @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 { class Doctrine_Connection_Mssql extends Doctrine_Connection {
/** /**
...@@ -39,16 +42,50 @@ 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) { public function __construct(Doctrine_Manager $manager, PDO $pdo) {
// initialize all driver options // 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); 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 * returns the next value in the given sequence
* *
* @param string $sequence name of the sequence * @param string $sequence name of the sequence
* @return integer the next value in the given 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)"); $this->query("INSERT INTO $sequence (vapor) VALUES (0)");
$stmt = $this->query("SELECT @@IDENTITY FROM $sequence"); $stmt = $this->query("SELECT @@IDENTITY FROM $sequence");
$data = $stmt->fetch(PDO::FETCH_NUM); $data = $stmt->fetch(PDO::FETCH_NUM);
...@@ -64,8 +101,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -64,8 +101,8 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
* @return string * @return string
*/ */
public function modifyLimitQuery($query, $limit, $offset) { public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
if ($limit) { if($limit > 0) {
// we need the starting SELECT clause for later // we need the starting SELECT clause for later
$select = 'SELECT '; $select = 'SELECT ';
...@@ -77,7 +114,7 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -77,7 +114,7 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
// is there an offset? // is there an offset?
if (! $offset) { if (! $offset) {
// no offset, it's a simple TOP count // 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. // the total of the count **and** the offset, combined.
...@@ -108,5 +145,27 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -108,5 +145,27 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
return $query; 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'); ...@@ -24,7 +24,10 @@ Doctrine::autoload('Doctrine_Connection_Common');
* *
* @package Doctrine ORM * @package Doctrine ORM
* @url www.phpdoctrine.com * @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 { class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
/** /**
......
...@@ -115,13 +115,14 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection { ...@@ -115,13 +115,14 @@ class Doctrine_Connection_Oracle extends Doctrine_Connection {
* @return void * @return void
*/ */
public function setTransactionIsolation($isolation) { public function setTransactionIsolation($isolation) {
switch ($isolation) { switch($isolation) {
case 'READ UNCOMMITTED': case 'READ UNCOMMITTED':
$isolation = 'READ COMMITTED'; $isolation = 'READ COMMITTED';
break;
case 'READ COMMITTED': case 'READ COMMITTED':
case 'REPEATABLE READ': case 'REPEATABLE READ':
$isolation = 'SERIALIZABLE';
case 'SERIALIZABLE': case 'SERIALIZABLE':
$isolation = 'SERIALIZABLE';
break; break;
default: default:
throw new Doctrine_Connection_Oracle_Exception('Isolation level ' . $isolation . ' is not supported.'); throw new Doctrine_Connection_Oracle_Exception('Isolation level ' . $isolation . ' is not supported.');
......
...@@ -24,7 +24,10 @@ Doctrine::autoload("Doctrine_Connection_Common"); ...@@ -24,7 +24,10 @@ Doctrine::autoload("Doctrine_Connection_Common");
* *
* @package Doctrine ORM * @package Doctrine ORM
* @url www.phpdoctrine.com * @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 { class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment