ABLE 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 $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 $hasMoveFirst = true;
var $hasGenID = true;
var $_genIDSQL = "SELECT NEXTVAL('%s')";
var $_genSeqSQL = "CREATE SEQUENCE %s START %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
// http://bugs.php.net/bug.php?id=25404
var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database
// The last (fmtTimeStamp is not entirely correct:
// PostgreSQL also has support for time zones,
// and writes these time in this format: "2001-03-01 18:59:26+02".
// There is no code for the "+02" time zone information, so I just left that out.
// I'm not familiar enough with both ADODB as well as Postgres
// to know what the concequences are. The other values are correct (wheren't in 0.94)
// -- Freek Dijkstra
function ADODB_postgres64()
{
// changes the metaColumnsSQL, adds columns: attnum[6]
}
function ServerInfo()
{
if (isset($this->version)) return $this->version;
$arr['description'] = $this->GetOne("select version()");
$arr['version'] = ADOConnection::_findvers($arr['description']);
$this->version = $arr;
return $arr;
}
/*
function IfNull( $field, $ifNull )
{
return " NULLIF($field, $ifNull) "; // if PGSQL
}
*/
// get the last id - never tested
function pg_insert_id($tablename,$fieldname)
{
$result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq");
if ($result) {
$arr = @pg_fetch_row($result,0);
pg_freeresult($result);
if (isset($arr[0])) return $arr[0];
}
return false;
}
/* Warning from http://www.php.net/manual/function.pg-getlastoid.php:
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()
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
return pg_getlastoid($this->_resultid);
}
// 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
function _affectedrows()
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
return pg_cmdtuples($this->_resultid);
}
// returns true/false
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
return @pg_Exec($this->_connectionID, "begin");
}
function RowLock($tables,$where)
{
if (!$this->transCnt) $this->BeginTrans();
return $this->GetOne("select 1 as ignore from $tables where $where for update");
}
// returns true/false.
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
$this->transCnt -= 1;
return @pg_Exec($this->_connectionID, "commit");
}
// returns true/false
function RollbackTrans()
{
if ($this->transOff) return true;
$this->transCnt -= 1;
return @pg_Exec($this->_connectionID, "rollback");
}
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
{
if ($mask) {
$save = $this->metaTablesSQ