summaryrefslogtreecommitdiff
path: root/includes/db/DatabasePostgres.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/db/DatabasePostgres.php')
-rw-r--r--includes/db/DatabasePostgres.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php
index 065ad56d..7d93fddf 100644
--- a/includes/db/DatabasePostgres.php
+++ b/includes/db/DatabasePostgres.php
@@ -72,6 +72,7 @@ class DatabasePostgres extends Database {
var $mInsertId = NULL;
var $mLastResult = NULL;
var $numeric_version = NULL;
+ var $mAffectedRows = NULL;
function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false,
$failFunction = false, $flags = 0 )
@@ -546,9 +547,11 @@ class DatabasePostgres extends Database {
function doQuery( $sql ) {
if (function_exists('mb_convert_encoding')) {
- return $this->mLastResult=pg_query( $this->mConn , mb_convert_encoding($sql,'UTF-8') );
+ $sql = mb_convert_encoding($sql,'UTF-8');
}
- return $this->mLastResult=pg_query( $this->mConn , $sql);
+ $this->mLastResult = pg_query( $this->mConn, $sql);
+ $this->mAffectedRows = NULL; // use pg_affected_rows(mLastResult)
+ return $this->mLastResult;
}
function queryIgnore( $sql, $fname = '' ) {
@@ -641,9 +644,12 @@ class DatabasePostgres extends Database {
}
function affectedRows() {
- if( !isset( $this->mLastResult ) or ! $this->mLastResult )
+ if ( !is_null( $this->mAffectedRows ) ) {
+ // Forced result for simulated queries
+ return $this->mAffectedRows;
+ }
+ if( empty( $this->mLastResult ) )
return 0;
-
return pg_affected_rows( $this->mLastResult );
}
@@ -809,7 +815,6 @@ class DatabasePostgres extends Database {
$sql .= '(' . $this->makeList( $args ) . ')';
$res = (bool)$this->query( $sql, $fname, $ignore );
-
if ( $ignore ) {
$bar = pg_last_error();
if ($bar != false) {
@@ -821,13 +826,15 @@ class DatabasePostgres extends Database {
}
}
}
-
if ( $ignore ) {
$olde = error_reporting( $olde );
if ($didbegin) {
$this->commit();
}
+ // Set the affected row count for the whole operation
+ $this->mAffectedRows = $numrowsinserted;
+
// IGNORE always returns true
return true;
}
@@ -1271,6 +1278,8 @@ END;
function addQuotes( $s ) {
if ( is_null( $s ) ) {
return 'NULL';
+ } else if ( is_bool( $s ) ) {
+ return intval( $s );
} else if ($s instanceof Blob) {
return "'".$s->fetch($s)."'";
}