adodb updates

This commit is contained in:
Shish
2010-07-19 13:09:32 +01:00
parent 1f44bed8d3
commit d6392dfd44
15 changed files with 1085 additions and 620 deletions

View File

@@ -1,6 +1,6 @@
<?php
/*
V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
V5.11 5 May 2010 (c) 2000-2010 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.
@@ -104,7 +104,8 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
var $random = 'random()'; /// random function
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.
@@ -177,10 +178,10 @@ a different OID if a database must be reloaded. */
return @pg_Exec($this->_connectionID, "begin ".$this->_transmode);
}
function RowLock($tables,$where,$flds='1 as ignore')
function RowLock($tables,$where,$col='1 as adodbignore')
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select $flds from $tables where $where for update");
return $this->GetOne("select $col from $tables where $where for update");
}
// returns true/false.
@@ -201,7 +202,7 @@ a different OID if a database must be reloaded. */
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) {
@@ -224,7 +225,7 @@ 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;
@@ -236,6 +237,8 @@ select viewname,'V' from pg_views where viewname like $mask";
// 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) {
return "'".pg_escape_string($this->_connectionID,$s)."'";
@@ -457,14 +460,17 @@ select viewname,'V' from pg_views where viewname like $mask";
if (10 <= $len && $len <= 12) $date = 'date '.$date;
else $date = 'timestamp '.$date;
}
return "($date+interval'$dayFraction days')";
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
// see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info
function &MetaColumns($table,$normalize=true)
function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;
@@ -478,8 +484,8 @@ select viewname,'V' from pg_views where viewname like $mask";
$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));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
@@ -496,7 +502,7 @@ select viewname,'V' from pg_views where viewname like $mask";
$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;
@@ -578,7 +584,7 @@ select viewname,'V' from pg_views where viewname like $mask";
}
function &MetaIndexes ($table, $primary = FALSE)
function MetaIndexes ($table, $primary = FALSE, $owner = false)
{
global $ADODB_FETCH_MODE;
@@ -659,7 +665,7 @@ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))';
if (strlen($db) == 0) $db = 'template1';
$db = adodb_addslashes($db);
if ($str) {
$host = split(":", $str);
$host = explode(":", $str);
if ($host[0]) $str = "host=".adodb_addslashes($host[0]);
else $str = '';
if (isset($host[1])) $str .= " port=$host[1]";
@@ -713,7 +719,7 @@ WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))';
// returns queryID or false
function _query($sql,$inputarr)
function _query($sql,$inputarr=false)
{
$this->_errorMsg = false;
if ($inputarr) {
@@ -886,10 +892,10 @@ class ADORecordSet_postgres64 extends ADORecordSet{
$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;
}
@@ -925,7 +931,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return $this->fields[$this->bind[strtoupper($colname)]];
}
function &FetchField($off = 0)
function FetchField($off = 0)
{
// offsets begin at 0
@@ -943,6 +949,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
function _decode($blob)
{
if ($blob === NULL) return NULL;
eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";');
return $realblob;
}
@@ -1049,7 +1056,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
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':