summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/adodb-postgres64.inc.php22
-rw-r--r--drivers/adodb-postgres7.inc.php27
2 files changed, 20 insertions, 29 deletions
diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php
index 4b1a3260..9583a3b1 100644
--- a/drivers/adodb-postgres64.inc.php
+++ b/drivers/adodb-postgres64.inc.php
@@ -1007,8 +1007,18 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return pg_unescape_bytea($blob);
}
+ function _prepfields()
+ {
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+ return $this->_fixblobs();
+ }
+
function _fixblobs()
{
+ // Check prerequisites and bail early if we do not have what we need.
+ if (!isset($this->_blobArr)) return false;
+ if ($this->fields === false) return false;
+
if ($this->fetchMode == PGSQL_NUM || $this->fetchMode == PGSQL_BOTH) {
foreach($this->_blobArr as $k => $v) {
$this->fields[$k] = ADORecordSet_postgres64::_decode($this->fields[$k]);
@@ -1019,6 +1029,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
$this->fields[$v] = ADORecordSet_postgres64::_decode($this->fields[$v]);
}
}
+ return true;
}
// 10% speedup to move MoveNext to child class
@@ -1027,11 +1038,8 @@ class ADORecordSet_postgres64 extends ADORecordSet{
if (!$this->EOF) {
$this->_currentRow++;
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
- $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
- if (is_array($this->fields) && $this->fields) {
- if (isset($this->_blobArr)) $this->_fixblobs();
- return true;
- }
+ $this->_prepfields();
+ if ($this->fields !== false) return true;
}
$this->fields = false;
$this->EOF = true;
@@ -1045,9 +1053,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return false;
}
- $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
-
- if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+ $this->_prepfields();
return (is_array($this->fields));
}
diff --git a/drivers/adodb-postgres7.inc.php b/drivers/adodb-postgres7.inc.php
index 08911033..52b59f71 100644
--- a/drivers/adodb-postgres7.inc.php
+++ b/drivers/adodb-postgres7.inc.php
@@ -299,12 +299,8 @@ class ADORecordSet_postgres7 extends ADORecordSet_postgres64{
if (!$this->EOF) {
$this->_currentRow++;
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
- $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
-
- if (is_array($this->fields)) {
- if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
- return true;
- }
+ $this->_prepfields();
+ if ($this->fields !== false) return true;
}
$this->fields = false;
$this->EOF = true;
@@ -325,12 +321,7 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
return false;
}
- $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
-
- if ($this->fields) {
- if (isset($this->_blobArr)) $this->_fixblobs();
- $this->_updatefields();
- }
+ if ($this->_prepfields()) $this->_updatefields();
return (is_array($this->fields));
}
@@ -340,19 +331,13 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
if (!$this->EOF) {
$this->_currentRow++;
if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
- $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
-
- if (is_array($this->fields)) {
- if ($this->fields) {
- if (isset($this->_blobArr)) $this->_fixblobs();
-
- $this->_updatefields();
- }
+ $this->_prepfields();
+ if ($this->fields !== false) {
+ $this->_updatefields();
return true;
}
}
-
$this->fields = false;
$this->EOF = true;
}