Updated pgsql connection driver
This commit is contained in:
parent
1df7817b37
commit
87f9122f7d
@ -59,19 +59,75 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
'identifier_quoting' => true,
|
||||
'pattern_escaping' => true,
|
||||
);
|
||||
|
||||
$this->options['multi_query'] = false;
|
||||
|
||||
parent::__construct($manager, $pdo);
|
||||
}
|
||||
/**
|
||||
* Set the charset on the current connection
|
||||
*
|
||||
* @param string charset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCharset($charset) {
|
||||
$query = 'SET NAMES '.$this->dbh->quote($charset);
|
||||
$this->dbh->query($query);
|
||||
}
|
||||
/**
|
||||
* returns the next value in the given sequence
|
||||
* @param string $sequence
|
||||
* @return integer
|
||||
*/
|
||||
public function getNextID($sequence) {
|
||||
$stmt = $this->query("SELECT NEXTVAL('$sequence')");
|
||||
public function nextId($sequence) {
|
||||
$stmt = $this->dbh->query("SELECT NEXTVAL('$sequence')");
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
}
|
||||
/**
|
||||
* Returns the current id of a sequence
|
||||
*
|
||||
* @param string $seq_name name of the sequence
|
||||
* @return mixed MDB2 Error Object or id
|
||||
* @access public
|
||||
*/
|
||||
function currId($sequence) {
|
||||
$stmt = $this->dbh->query('SELECT last_value FROM '.$sequence);
|
||||
$data = $stmt->fetch(PDO::FETCH_NUM);
|
||||
return $data[0];
|
||||
}
|
||||
/**
|
||||
* Changes a query string for various DBMS specific reasons
|
||||
*
|
||||
* @param string $query query to modify
|
||||
* @param integer $limit limit the number of rows
|
||||
* @param integer $offset start reading from given offset
|
||||
* @param boolean $isManip if the query is a DML query
|
||||
|
||||
* @return string modified query
|
||||
*/
|
||||
public function modifyLimitQuery($query, $limit, $offset, $isManip = false) {
|
||||
if ($limit > 0) {
|
||||
$query = rtrim($query);
|
||||
|
||||
if (substr($query, -1) == ';') {
|
||||
$query = substr($query, 0, -1);
|
||||
}
|
||||
|
||||
if ($isManip) {
|
||||
$manip = preg_replace('/^(DELETE FROM|UPDATE).*$/', '\\1', $query);
|
||||
$from = $match[2];
|
||||
$where = $match[3];
|
||||
$query = $manip . ' ' . $from . ' WHERE ctid=(SELECT ctid FROM '
|
||||
. $from . ' ' . $where . ' LIMIT ' . $limit . ')';
|
||||
|
||||
} else {
|
||||
$query .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* Set the transacton isolation level.
|
||||
*
|
||||
@ -82,7 +138,7 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
|
||||
* SERIALIZABLE (prevents phantom reads)
|
||||
* @return void
|
||||
*/
|
||||
function setTransactionIsolation($isolation) {
|
||||
public function setTransactionIsolation($isolation) {
|
||||
switch ($isolation) {
|
||||
case 'READ UNCOMMITTED':
|
||||
case 'READ COMMITTED':
|
||||
|
Loading…
x
Reference in New Issue
Block a user