Source for file adodb-informix72.inc.php
Documentation is available at adodb-informix72.inc.php
V4.97 22 Jan 2008 (c) 2000-2008 John Lim. 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.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Informix port by Mitchell T. Young (mitch@youngfamily.org)
Further mods by "Samuel CARRIERE" <samuel_carriere@hotmail.com>
var $metaTablesSQL= "select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables
"select c.colname, c.coltype, c.collength, d.default,c.colno
from syscolumns c, systables t,outer sysdefaults d
where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno
and tabname='%s' order by c.colno";
"select part1,part2,part3,part4,part5,part6,part7,part8 from
systables t,sysconstraints s,sysindexes i where t.tabname='%s'
and s.tabid=t.tabid and s.constrtype='P'
and i.idxname=s.idxname";
var $_bindInputArray = true; // set to true if ADOConnection.Execute() permits binding of array parameters.
var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0
// alternatively, use older method:
//putenv("DBDATE=Y4MD-");
ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content.
ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content.
ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file.
if (isset ($this->version)) return $this->version;
$arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1");
$arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1");
return @$sqlca["sqlerrd1"];
return @ifx_affected_rows ($this->lastQuery);
function RowLock($tables,$where,$flds= '1 as ignore')
return $this->GetOne("select $flds from $tables where $where for update");
/* Returns: the last error message from previous database operation
Note: This function is NOT available for Microsoft SQL Server. */
preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse);
if (is_array($parse) && isset ($parse[1])) return (int) $parse[1];
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = $save;
if ($rs === false) return $false;
while (!$rs->EOF) { //print_r($rs->fields);
$fld->name = $rs->fields[0];
$rs->fields[1] is not the correct adodb type
$rs->fields[2] is not correct max_length, because can include not-null bit
$fld->type = $rs->fields[1];
$fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag
$fld->max_length = $rs->fields[2];*/
$pr= ifx_props($rs->fields[1],$rs->fields[2]); //!eos
$fld->type = $pr[0] ;//!eos
$fld->primary_key= $rspkey->fields && array_search($rs->fields[4],$rspkey->fields);
$fld->max_length = $pr[1]; //!eos
$fld->precision = $pr[2] ;//!eos
$fld->not_null = $pr[3]== "N"; //!eos
if (trim($rs->fields[3]) != "AAAAAA 0") {
$fld->default_value = $rs->fields[3];
select tr.tabname,updrule,delrule,
i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4,
i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8
from systables t,sysconstraints s,sysindexes i,
sysreferences r,systables tr,sysconstraints s2,sysindexes i2
and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid
and i.idxname=s.idxname and tr.tabid=r.ptabid
and s2.constrid=r.primary and i2.idxname=s2.idxname";
if (!$rs || $rs->EOF) return false;
$coldest= $this->metaColumnNames($v["tabname"]);
$colorig= $this->metaColumnNames($table);
for($i= 1;$i<= 8 && $v["o$i"] ;$i++ ) {
$colnames[]= $coldest[$v["d$i"]- 1]. "=". $colorig[$v["o$i"]- 1];
$a[$v["tabname"]] = $colnames;
function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
$type = ($blobtype == 'TEXT') ? 1 : 0;
$blobid = ifx_create_blob($type,0,$val);
return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blobid));
return function_exists('ifx_byteasvarchar') ? $blobid : @ifx_get_blob($blobid);
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
$dbs = $argDatabasename . "@" . $argHostname;
if ($argHostname) putenv("INFORMIXSERVER=$argHostname");
$this->_connectionID = ifx_connect($dbs,$argUsername,$argPassword);
#if ($argDatabasename) return $this->SelectDB($argDatabasename);
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
$dbs = $argDatabasename . "@" . $argHostname;
$this->_connectionID = ifx_pconnect($dbs,$argUsername,$argPassword);
#if ($argDatabasename) return $this->SelectDB($argDatabasename);
// ifx_do does not accept bind parameters - weird ???
$stmt = ifx_prepare($sql);
else return array($sql,$stmt);
// returns query ID if successful, otherwise false
function _query($sql,$inputarr)
// String parameters have to be converted using ifx_create_char
foreach($inputarr as $v) {
$tab[] = ifx_create_char($v);
// In case of select statement, we use a scroll cursor in order
// to be able to call "move", or "movefirst" statements
if (!$ADODB_COUNTRECS && preg_match("/^\s*select/is", $sql)) {
// Following line have been commented because autocommit mode is
// not supported by informix SE 7.2
//if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID);
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
/* Returns: an object containing field information.
Get column information in the Recordset object. fetchField() can be used in order to obtain information about
fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
fetchField() is retrieved. */
$fp = ifx_fieldproperties($this->_queryID);
foreach($fp as $k => $v) {
$arr = split(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE"
$o->max_length = $arr[1];
$o->not_null = $arr[4]== "N";
$this->_numOfRows = - 1; // ifx_affected_rows not reliable, only returns estimate -- ($ADODB_COUNTRECS)? ifx_affected_rows($this->_queryID):-1;
return @ifx_fetch_row($this->_queryID, (int) $row);
foreach($this->fields as $v) {
foreach($this->fields as $v) {
function _fetch($ignore_fields= false)
foreach($this->fields as $v) {
/* close() only needs to be called if you are worried about using too much memory while your script
is running. All associated result memory for the specified result identifier will automatically be freed. */
return ifx_free_result($this->_queryID);
* Auxiliar function to Parse coltype,collength. Used by Metacolumns
* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties)
$itype= fmod($coltype+ 1,256);
$nullable= floor(($coltype+ 1) / 256) ? "N": "Y";
$mtype= substr(" CIIFFNNDN TBXCC ",$itype,1);
$length= floor($collength/ 256);
$precision= fmod($collength,256);
return array($mtype,$length,$precision,$nullable);
|