summaryrefslogtreecommitdiff
path: root/includes/db
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-09-06 22:50:34 +0200
committerPierre Schmitz <pierre@archlinux.de>2008-09-06 22:50:34 +0200
commit24c464c9ee15b0d204c41fcd212975ebc7864904 (patch)
treeacc6d8db225ed165010993fe0f11884411dc264d /includes/db
parent5521bad534edbcfca285393e36a6a94a3f1be9bf (diff)
Aktualisierung auf 1.13.1
Diffstat (limited to 'includes/db')
-rw-r--r--includes/db/DatabasePostgres.php21
-rw-r--r--includes/db/DatabaseSqlite.php11
2 files changed, 24 insertions, 8 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)."'";
}
diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php
index 5299c688..112c417b 100644
--- a/includes/db/DatabaseSqlite.php
+++ b/includes/db/DatabaseSqlite.php
@@ -289,15 +289,22 @@ class DatabaseSqlite extends Database {
}
function encodeBlob($b) {
- return $this->strencode($b);
+ return new Blob( $b );
}
function decodeBlob($b) {
+ if ($b instanceof Blob) {
+ $b = $b->fetch();
+ }
return $b;
}
function addQuotes($s) {
- return $this->mConn->quote($s);
+ if ( $s instanceof Blob ) {
+ return "x'" . bin2hex( $s->fetch() ) . "'";
+ } else {
+ return $this->mConn->quote($s);
+ }
}
function quote_ident($s) { return $s; }