<?php
/*
- V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
+ V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
function adodb_addslashes($s)
{
$len = strlen($s);
if ($len == 0) return "''";
- if (strncmp($s,"'",1) === 0 && substr(s,$len-1) == "'") return $s; // already quoted
+ if (strncmp($s,"'",1) === 0 && substr($s,$len-1) == "'") return $s; // already quoted
return "'".addslashes($s)."'";
}
var $_resultid = false;
var $concat_operator='||';
var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
- var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' union
+ var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages',
+ 'sql_packages', 'sql_sizing', 'sql_sizing_profiles')
+ union
select viewname,'V' from pg_views where viewname not like 'pg\_%'";
//"select tablename from pg_tables where tablename not like 'pg_%' order by 1";
var $isoDates = true; // accepts dates in ISO format
var $blobEncodeType = 'C';
var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum
FROM pg_class c, pg_attribute a,pg_type t
- WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%'
+ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%'
AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+ // used when schema defined
var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n
-WHERE relkind = 'r' AND (c.relname='%s' or c.relname = lower('%s'))
+WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
and c.relnamespace=n.oid and n.nspname='%s'
and a.attname not like '....%%' AND a.attnum > 0
AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
var $hasAffectedRows = true;
var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
// below suggested by Freek Dijkstra
- var $true = 't'; // string that represents TRUE for a database
- var $false = 'f'; // string that represents FALSE for a database
+ var $true = 'TRUE'; // string that represents TRUE for a database
+ var $false = 'FALSE'; // string that represents FALSE for a database
var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
- var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
+ var $fmtTimeStamp = "'Y-m-d H:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
var $hasMoveFirst = true;
var $hasGenID = true;
var $_genIDSQL = "SELECT NEXTVAL('%s')";
var $_dropSeqSQL = "DROP SEQUENCE %s";
var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
var $random = 'random()'; /// random function
- var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
+ var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
// http://bugs.php.net/bug.php?id=25404
-
+
+ var $uniqueIisR = true;
var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database
+ var $disableBlobs = false; // set to true to disable blob checking, resulting in 2-5% improvement in performance.
+
+ var $_pnum = 0;
// The last (fmtTimeStamp is not entirely correct:
// PostgreSQL also has support for time zones,
$this->version = $arr;
return $arr;
}
-/*
+
function IfNull( $field, $ifNull )
{
- return " NULLIF($field, $ifNull) "; // if PGSQL
+ return " coalesce($field, $ifNull) ";
}
-*/
+
// get the last id - never tested
function pg_insert_id($tablename,$fieldname)
{
Using a OID as a unique identifier is not generally wise.
Unless you are very careful, you might end up with a tuple having
a different OID if a database must be reloaded. */
- function _insertid()
+ function _insertid($table,$column)
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
- return pg_getlastoid($this->_resultid);
+ $oid = pg_getlastoid($this->_resultid);
+ // to really return the id, we need the table and column-name, else we can only return the oid != id
+ return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
}
// I get this error with PHP before 4.0.6 - jlim
-// Warning: This compilation does not support pg_cmdtuples() in d:/inetpub/wwwroot/php/adodb/adodb-postgres.inc.php on line 44
+// Warning: This compilation does not support pg_cmdtuples() in adodb-postgres.inc.php on line 44
function _affectedrows()
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
{
if ($this->transOff) return true;
$this->transCnt += 1;
- return @pg_Exec($this->_connectionID, "begin");
+ return @pg_Exec($this->_connectionID, "begin ".$this->_transmode);
}
- function RowLock($tables,$where)
+ function RowLock($tables,$where,$col='1 as adodbignore')
{
if (!$this->transCnt) $this->BeginTrans();
- return $this->GetOne("select 1 as ignore from $tables where $where for update");
+ return $this->GetOne("select $col from $tables where $where for update");
}
// returns true/false.
return @pg_Exec($this->_connectionID, "rollback");
}
- function &MetaTables($ttype=false,$showSchema=false,$mask=false)
- {
+ function MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $info = $this->ServerInfo();
+ if ($info['version'] >= 7.3) {
+ $this->metaTablesSQL = "select table_name,'T' from information_schema.tables where table_schema not in ( 'pg_catalog','information_schema')
+ union
+ select table_name,'V' from information_schema.views where table_schema not in ( 'pg_catalog','information_schema') ";
+ }
if ($mask) {
$save = $this->metaTablesSQL;
$mask = $this->qstr(strtolower($mask));
- $this->metaTablesSQL = "
-select tablename,'T' from pg_tables where tablename like $mask union
+ if ($info['version']>=7.3)
+ $this->metaTablesSQL = "select table_name,'T' from information_schema.tables where table_name like $mask and table_schema not in ( 'pg_catalog','information_schema')
+ union
+ select table_name,'V' from information_schema.views where table_name like $mask and table_schema not in ( 'pg_catalog','information_schema') ";
+ else
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask
+ union
select viewname,'V' from pg_views where viewname like $mask";
}
- $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+ $ret = ADOConnection::MetaTables($ttype,$showSchema);
if ($mask) {
$this->metaTablesSQL = $save;
return $ret;
}
- /*
+
// if magic quotes disabled, use pg_escape_string()
function qstr($s,$magic_quotes=false)
{
+ if (is_bool($s)) return $s ? 'true' : 'false';
+
if (!$magic_quotes) {
+ if (ADODB_PHPVER >= 0x5200 && $this->_connectionID) {
+ return "'".pg_escape_string($this->_connectionID,$s)."'";
+ }
if (ADODB_PHPVER >= 0x4200) {
return "'".pg_escape_string($s)."'";
}
if ($this->replaceQuote[0] == '\\'){
- $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\\000"),$s);
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
$s = str_replace('\\"','"',$s);
return "'$s'";
}
- */
+
// Format date column in sql string given an input format that understands Y M D
$s .= 'AM';
break;
+ case 'w':
+ $s .= 'D';
+ break;
+
+ case 'l':
+ $s .= 'DAY';
+ break;
+
+ case 'W':
+ $s .= 'WW';
+ break;
+
default:
// handle escape characters...
if ($ch == '\\') {
return $rez;
}
+ /*
+ * Deletes/Unlinks a Blob from the database, otherwise it
+ * will be left behind
+ *
+ * Returns TRUE on success or FALSE on failure.
+ *
+ * contributed by Todd Rogers todd#windfox.net
+ */
+ function BlobDelete( $blob )
+ {
+ pg_exec ($this->_connectionID, "begin");
+ $result = @pg_lo_unlink($blob);
+ pg_exec ($this->_connectionID, "commit");
+ return( $result );
+ }
+
+ /*
+ Hueristic - not guaranteed to work.
+ */
+ function GuessOID($oid)
+ {
+ if (strlen($oid)>16) return false;
+ return is_numeric($oid);
+ }
+
/*
* If an OID is detected, then we use pg_lo_* to open the oid file and read the
* real blob from the db using the oid supplied as a parameter. If you are storing
* contributed by Mattia Rossi mattia@technologist.com
*
* see http://www.postgresql.org/idocs/index.php?largeobjects.html
+ *
+ * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also
+ * added maxsize parameter, which defaults to $db->maxblobsize if not defined.
*/
- function BlobDecode( $blob)
- {
- if (strlen($blob) > 24) return $blob;
+ function BlobDecode($blob,$maxsize=false,$hastrans=true)
+ {
+ if (!$this->GuessOID($blob)) return $blob;
- @pg_exec($this->_connectionID,"begin");
+ if ($hastrans) @pg_exec($this->_connectionID,"begin");
$fd = @pg_lo_open($this->_connectionID,$blob,"r");
if ($fd === false) {
- @pg_exec($this->_connectionID,"commit");
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
return $blob;
}
- $realblob = @pg_loreadall($fd);
+ if (!$maxsize) $maxsize = $this->maxblobsize;
+ $realblob = @pg_loread($fd,$maxsize);
@pg_loclose($fd);
- @pg_exec($this->_connectionID,"commit");
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
return $realblob;
- }
+ }
/*
See http://www.postgresql.org/idocs/index.php?datatype-binary.html
*/
function BlobEncode($blob)
{
+ if (ADODB_PHPVER >= 0x5200) return pg_escape_bytea($this->_connectionID, $blob);
if (ADODB_PHPVER >= 0x4200) return pg_escape_bytea($blob);
/*92=backslash, 0=null, 39=single-quote*/
// note that there is a pg_escape_bytea function only for php 4.2.0 or later
}
+ // assumes bytea for blob, and varchar for clob
function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
{
+ if ($blobtype == 'CLOB') {
+ return $this->Execute("UPDATE $table SET $column=" . $this->qstr($val) . " WHERE $where");
+ }
// do not use bind params which uses qstr(), as blobencode() already quotes data
return $this->Execute("UPDATE $table SET $column='".$this->BlobEncode($val)."'::bytea WHERE $where");
}
function OffsetDate($dayFraction,$date=false)
{
if (!$date) $date = $this->sysDate;
- return "($date+interval'$dayFraction days')";
+ else if (strncmp($date,"'",1) == 0) {
+ $len = strlen($date);
+ if (10 <= $len && $len <= 12) $date = 'date '.$date;
+ else $date = 'timestamp '.$date;
+ }
+
+
+ return "($date+interval'".($dayFraction * 1440)." minutes')";
+ #return "($date+interval'$dayFraction days')";
}
// for schema support, pass in the $table param "$schema.$tabname".
// converts field names to lowercase, $upper is ignored
- function &MetaColumns($table,$upper=true)
+ // see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info
+ function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;
$schema = false;
+ $false = false;
$this->_findschema($table,$schema);
- $table = strtolower($table);
+ if ($normalize) $table = strtolower($table);
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
- if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
- else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
+ if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
+ else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table,$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
- if ($rs === false) return false;
-
+ if ($rs === false) {
+ return $false;
+ }
if (!empty($this->metaKeySQL)) {
// If we want the primary keys, we have to issue a separate query
// Of course, a modified version of the metaColumnsSQL query using a
$rskey = $this->Execute(sprintf($this->metaKeySQL,($table)));
// fetch all result in once for performance.
- $keys =& $rskey->GetArray();
+ $keys = $rskey->GetArray();
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
while (!$rsdef->EOF) {
$num = $rsdef->fields['num'];
$s = $rsdef->fields['def'];
- if (substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
+ if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
$s = substr($s, 1);
$s = substr($s, 0, strlen($s) - 1);
}
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
$fld->max_length = $rs->fields[2];
+ $fld->attnum = $rs->fields[6];
+
if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4;
if ($fld->max_length <= 0) $fld->max_length = -1;
-
+ if ($fld->type == 'numeric') {
+ $fld->scale = $fld->max_length & 0xFFFF;
+ $fld->max_length >>= 16;
+ }
// dannym
// 5 hasdefault; 6 num-of-column
$fld->has_default = ($rs->fields[5] == 't');
}
//Freek
- if ($rs->fields[4] == $this->true) {
- $fld->not_null = true;
- }
+ $fld->not_null = $rs->fields[4] == 't';
+
// Freek
if (is_array($keys)) {
foreach($keys as $key) {
- if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true)
+ if ($fld->name == $key['column_name'] AND $key['primary_key'] == 't')
$fld->primary_key = true;
- if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true)
+ if ($fld->name == $key['column_name'] AND $key['unique_key'] == 't')
$fld->unique = true; // What name is more compatible?
}
}
if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
- else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
+ else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;
$rs->MoveNext();
}
$rs->Close();
- return $retarr;
+ if (empty($retarr))
+ return $false;
+ else
+ return $retarr;
}
-
- function &MetaIndexes ($table, $primary = FALSE)
+
+ function Param($name,$type='C')
+ {
+ $this->_pnum += 1;
+ return '$'.$this->_pnum;
+ }
+
+ function MetaIndexes ($table, $primary = FALSE, $owner = false)
{
global $ADODB_FETCH_MODE;
$schema = false;
$this->_findschema($table,$schema);
-
+
if ($schema) { // requires pgsql 7.3+ - pg_namespace used.
$sql = '
SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns"
JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
,pg_namespace n
-WHERE c2.relname=\'%s\' and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false';
+WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\'';
} else {
$sql = '
SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns"
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
-WHERE c2.relname=\'%s\'';
+WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))';
}
if ($primary == FALSE) {
- $sql .= ' AND i.indisprimary=false;';
+ $sql .= ' AND i.indisprimary=false;';
}
$save = $ADODB_FETCH_MODE;
$savem = $this->SetFetchMode(FALSE);
}
- $rs = $this->Execute(sprintf($sql,$table,$schema));
-
+ $rs = $this->Execute(sprintf($sql,$table,$table,$schema));
if (isset($savem)) {
$this->SetFetchMode($savem);
}
$ADODB_FETCH_MODE = $save;
-
+
if (!is_object($rs)) {
- return FALSE;
+ $false = false;
+ return $false;
}
-
- $col_names = $this->MetaColumnNames($table);
+
+ $col_names = $this->MetaColumnNames($table,true,true);
+ //3rd param is use attnum,
+ // see http://sourceforge.net/tracker/index.php?func=detail&aid=1451245&group_id=42718&atid=433976
$indexes = array();
-
while ($row = $rs->FetchRow()) {
$columns = array();
-
foreach (explode(' ', $row[2]) as $col) {
- $columns[] = $col_names[$col - 1];
+ $columns[] = $col_names[$col];
}
$indexes[$row[0]] = array(
'columns' => $columns
);
}
-
return $indexes;
}
function _connect($str,$user='',$pwd='',$db='',$ctype=0)
{
- if (!function_exists('pg_pconnect')) return false;
+ if (!function_exists('pg_connect')) return null;
$this->_errorMsg = false;
if ($str) {
$host = explode(":", $str);
if ($host[0]) $str = "host=".adodb_addslashes($host[0]);
- else $str = 'host=localhost';
+ else $str = '';
if (isset($host[1])) $str .= " port=$host[1]";
+ else if (!empty($this->port)) $str .= " port=".$this->port;
}
if ($user) $str .= " user=".$user;
if ($pwd) $str .= " password=".$pwd;
}
if ($this->_connectionID === false) return false;
$this->Execute("set datestyle='ISO'");
+
+ $info = $this->ServerInfo();
+ $this->pgVersion = (float) substr($info['version'],0,3);
+ if ($this->pgVersion >= 7.1) { // good till version 999
+ $this->_nestedSQL = true;
+ }
return true;
}
// returns queryID or false
- function _query($sql,$inputarr)
+ function _query($sql,$inputarr=false)
{
-
+ $this->_pnum = 0;
+ $this->_errorMsg = false;
if ($inputarr) {
/*
It appears that PREPARE/EXECUTE is slower for many queries.
if ($execp) $exsql = "EXECUTE $plan ($execp)";
else $exsql = "EXECUTE $plan";
+
$rez = @pg_exec($this->_connectionID,$exsql);
if (!$rez) {
# Perhaps plan does not exist? Prepare/compile plan.
if ($params) $params .= ',';
if (is_string($v)) {
$params .= 'VARCHAR';
- } elseif (is_integer($v)) {
+ } else if (is_integer($v)) {
$params .= 'INTEGER';
} else {
$params .= "REAL";
}
$s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2);
//adodb_pr($s);
- pg_exec($this->_connectionID,$s);
- echo $this->ErrorMsg();
+ $rez = pg_exec($this->_connectionID,$s);
+ //echo $this->ErrorMsg();
}
-
- $rez = pg_exec($this->_connectionID,$exsql);
+ if ($rez)
+ $rez = pg_exec($this->_connectionID,$exsql);
} else {
- $this->_errorMsg = false;
//adodb_backtrace();
$rez = pg_exec($this->_connectionID,$sql);
}
return $rez;
}
+ function _errconnect()
+ {
+ if (defined('DB_ERROR_CONNECT_FAILED')) return DB_ERROR_CONNECT_FAILED;
+ else return 'Database connection failed';
+ }
/* Returns: the last error message from previous database operation */
function ErrorMsg()
if (!empty($this->_connectionID)) {
$this->_errorMsg = @pg_last_error($this->_connectionID);
- } else $this->_errorMsg = @pg_last_error();
+ } else $this->_errorMsg = $this->_errconnect();
} else {
- if (empty($this->_connectionID)) $this->_errorMsg = @pg_errormessage();
+ if (empty($this->_connectionID)) $this->_errconnect();
else $this->_errorMsg = @pg_errormessage($this->_connectionID);
}
return $this->_errorMsg;
function ErrorNo()
{
$e = $this->ErrorMsg();
- return strlen($e) ? $e : 0;
+ if (strlen($e)) {
+ return ADOConnection::MetaError($e);
+ }
+ return 0;
}
// returns true or false
{
case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
- default:
+
case ADODB_FETCH_DEFAULT:
- case ADODB_FETCH_BOTH:$this->fetchMode = PGSQL_BOTH; break;
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = PGSQL_BOTH; break;
}
+ $this->adodbFetchMode = $mode;
$this->ADORecordSet($queryID);
}
- function &GetRowAssoc($upper=true)
+ function GetRowAssoc($upper=true)
{
if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields;
- $row =& ADORecordSet::GetRowAssoc($upper);
+ $row = ADORecordSet::GetRowAssoc($upper);
return $row;
}
+
function _initrs()
{
$this->_numOfFields = @pg_numfields($qid);
// cache types for blob decode check
+ // apparently pg_fieldtype actually performs an sql query on the database to get the type.
+ if (empty($this->connection->noBlobs))
for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
if (pg_fieldtype($qid,$i) == 'bytea') {
- $this->_blobArr[$i] = pg_fieldname($qid,$off);
+ $this->_blobArr[$i] = pg_fieldname($qid,$i);
}
- }
+ }
}
/* Use associative array to get fields array */
return $this->fields[$this->bind[strtoupper($colname)]];
}
- function &FetchField($fieldOffset = 0)
+ function FetchField($off = 0)
{
- $off=$fieldOffset; // offsets begin at 0
+ // offsets begin at 0
$o= new ADOFieldObject();
$o->name = @pg_fieldname($this->_queryID,$off);
function _decode($blob)
{
- eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";');
- return $realblob;
+ if ($blob === NULL) return NULL;
+// eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";');
+ return pg_unescape_bytea($blob);
}
function _fixblobs()
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 ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+ if (isset($this->_blobArr)) $this->_fixblobs();
return true;
}
}
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
- if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+ if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
return (is_array($this->fields));
}
case 'NAME':
case 'BPCHAR':
case '_VARCHAR':
+ case 'INET':
+ case 'MACADDR':
if ($len <= $this->blobSize) return 'C';
case 'TEXT':
case 'DATE':
return 'D';
+
+ case 'TIMESTAMP WITHOUT TIME ZONE':
case 'TIME':
case 'DATETIME':
case 'TIMESTAMP':
case 'INT4':
case 'INT2':
if (isset($fieldobj) &&
- empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I';
+ empty($fieldobj->primary_key) && (!$this->connection->uniqueIisR || empty($fieldobj->unique))) return 'I';
case 'OID':
case 'SERIAL':
}
}
+?>
\ No newline at end of file