18 if (!defined(
'ADODB_DIR'))
die();
20 if (!defined(
'IFX_SCROLL')) define(
'IFX_SCROLL',1);
31 var
$metaTablesSQL=
"select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'";
35 "select c.colname, c.coltype, c.collength, d.default,c.colno 36 from syscolumns c, systables t,outer sysdefaults d 37 where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno 38 and tabname='%s' order by c.colno";
41 "select part1,part2,part3,part4,part5,part6,part7,part8 from 42 systables t,sysconstraints s,sysindexes i where t.tabname='%s' 43 and s.tabid=t.tabid and s.constrtype='P' 44 and i.idxname=s.idxname";
63 putenv(
'GL_DATE=%Y-%m-%d');
65 if (function_exists(
'ifx_byteasvarchar')) {
68 ifx_blobinfile_mode(0);
74 if (isset($this->version))
return $this->version;
76 $arr[
'description'] = $this->GetOne(
"select DBINFO('version','full') from systables where tabid = 1");
77 $arr[
'version'] = $this->GetOne(
"select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1");
78 $this->version = $arr;
86 $sqlca =ifx_getsqlca($this->lastQuery);
87 return @$sqlca[
"sqlerrd1"];
92 if ($this->lastQuery) {
93 return @ifx_affected_rows ($this->lastQuery);
100 if ($this->transOff)
return true;
101 $this->transCnt += 1;
102 $this->Execute(
'BEGIN');
103 $this->_autocommit =
false;
110 if ($this->transOff)
return true;
111 if ($this->transCnt) $this->transCnt -= 1;
112 $this->Execute(
'COMMIT');
113 $this->_autocommit =
true;
119 if ($this->transOff)
return true;
120 if ($this->transCnt) $this->transCnt -= 1;
121 $this->Execute(
'ROLLBACK');
122 $this->_autocommit =
true;
126 function RowLock($tables,$where,$col=
'1 as adodbignore')
129 return $this->GetOne(
"select $col from $tables where $where for update");
137 if (!empty($this->_logsql))
return $this->_errorMsg;
138 $this->_errorMsg = ifx_errormsg();
139 return $this->_errorMsg;
144 preg_match(
"/.*SQLCODE=([^\]]*)/",ifx_error(),$parse);
145 if (is_array($parse) && isset($parse[1]))
return (
int)$parse[1];
150 function MetaProcedures($NamePattern =
false, $catalog = null, $schemaPattern = null)
153 global $ADODB_FETCH_MODE;
156 $save = $ADODB_FETCH_MODE;
157 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
158 if ($this->fetchMode !== FALSE) {
159 $savem = $this->SetFetchMode(FALSE);
162 $procedures = array ();
168 $likepattern =
" WHERE procname LIKE '".$NamePattern.
"'";
171 $rs = $this->Execute(
'SELECT procname, isproc FROM sysprocedures'.$likepattern);
173 if (is_object(
$rs)) {
176 while ($row =
$rs->FetchRow()) {
177 $procedures[$row[0]] = array(
178 'type' => ($row[1] ==
'f' ?
'FUNCTION' :
'PROCEDURE'),
188 $this->SetFetchMode($savem);
190 $ADODB_FETCH_MODE = $save;
197 global $ADODB_FETCH_MODE;
200 if (!empty($this->metaColumnsSQL)) {
201 $save = $ADODB_FETCH_MODE;
202 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
203 if ($this->fetchMode !==
false) $savem = $this->SetFetchMode(
false);
204 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
205 if (isset($savem)) $this->SetFetchMode($savem);
206 $ADODB_FETCH_MODE = $save;
207 if (
$rs ===
false)
return $false;
208 $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table));
212 $fld =
new ADOFieldObject();
213 $fld->name =
$rs->fields[0];
222 $fld->type = $pr[0] ;
223 $fld->primary_key=$rspkey->fields && array_search(
$rs->fields[4],$rspkey->fields);
224 $fld->max_length = $pr[1];
225 $fld->precision = $pr[2] ;
226 $fld->not_null = $pr[3]==
"N";
228 if (trim(
$rs->fields[3]) !=
"AAAAAA 0") {
229 $fld->has_default = 1;
230 $fld->default_value =
$rs->fields[3];
232 $fld->has_default = 0;
235 $retarr[strtolower($fld->name)] = $fld;
249 return ADOConnection::MetaColumns($table,
false);
255 select tr.tabname,updrule,delrule, 256 i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4, 257 i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8 258 from systables t,sysconstraints s,sysindexes i, 259 sysreferences r,systables tr,sysconstraints s2,sysindexes i2 260 where t.tabname='$table' 261 and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid 262 and i.idxname=s.idxname and tr.tabid=r.ptabid 263 and s2.constrid=r.primary and i2.idxname=s2.idxname";
266 if (!
$rs ||
$rs->EOF)
return false;
267 $arr =
$rs->GetArray();
269 foreach($arr as $v) {
270 $coldest=$this->metaColumnNames($v[
"tabname"]);
271 $colorig=$this->metaColumnNames($table);
273 for($i=1;$i<=8 && $v[
"o$i"] ;$i++) {
274 $colnames[]=$coldest[$v[
"d$i"]-1].
"=".$colorig[$v[
"o$i"]-1];
277 $a[strtoupper($v[
"tabname"])] = $colnames;
279 $a[$v[
"tabname"]] = $colnames;
284 function UpdateBlob($table, $column, $val, $where, $blobtype =
'BLOB')
286 $type = ($blobtype ==
'TEXT') ? 1 : 0;
287 $blobid = ifx_create_blob($type,0,$val);
288 return $this->Execute(
"UPDATE $table SET $column=(?) WHERE $where",array($blobid));
293 return function_exists(
'ifx_byteasvarchar') ? $blobid : @ifx_get_blob($blobid);
297 function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
299 if (!function_exists(
'ifx_connect'))
return null;
301 $dbs = $argDatabasename .
"@" . $argHostname;
302 if ($argHostname) putenv(
"INFORMIXSERVER=$argHostname");
303 putenv(
"INFORMIXSERVER=".trim($argHostname));
304 $this->_connectionID = ifx_connect($dbs,$argUsername,$argPassword);
305 if ($this->_connectionID ===
false)
return false;
306 #if ($argDatabasename) return $this->SelectDB($argDatabasename); 311 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
313 if (!function_exists(
'ifx_connect'))
return null;
315 $dbs = $argDatabasename .
"@" . $argHostname;
316 putenv(
"INFORMIXSERVER=".trim($argHostname));
317 $this->_connectionID = ifx_pconnect($dbs,$argUsername,$argPassword);
318 if ($this->_connectionID ===
false)
return false;
319 #if ($argDatabasename) return $this->SelectDB($argDatabasename); 334 global $ADODB_COUNTRECS;
338 foreach($inputarr as $v) {
339 if (gettype($v) ==
'string') {
340 $tab[] = ifx_create_char($v);
350 if (!$ADODB_COUNTRECS && preg_match(
"/^\s*select/is",
$sql)) {
352 $this->lastQuery = ifx_query(
$sql,$this->_connectionID, $this->cursorType, $tab);
355 $this->lastQuery = ifx_query(
$sql,$this->_connectionID, $this->cursorType);
360 $this->lastQuery = ifx_query(
$sql,$this->_connectionID, $tab);
363 $this->lastQuery = ifx_query(
$sql,$this->_connectionID);
378 $this->lastQuery =
false;
379 return ifx_close($this->_connectionID);
392 var $_fieldprops =
false;
396 if ($mode ===
false) {
397 global $ADODB_FETCH_MODE;
398 $mode = $ADODB_FETCH_MODE;
400 $this->fetchMode = $mode;
401 return $this->ADORecordSet($id);
412 if (empty($this->_fieldprops)) {
413 $fp = ifx_fieldproperties($this->_queryID);
414 foreach($fp as $k => $v) {
415 $o =
new ADOFieldObject;
417 $arr = explode(
';',$v);
419 $o->max_length = $arr[1];
420 $this->_fieldprops[] = $o;
421 $o->not_null = $arr[4]==
"N";
424 $ret = $this->_fieldprops[$fieldOffset];
430 $this->_numOfRows = -1;
431 $this->_numOfFields = ifx_num_fields($this->_queryID);
436 return @ifx_fetch_row($this->_queryID, (
int) $row);
441 $this->fields = @ifx_fetch_row($this->_queryID,
"LAST");
442 if ($this->fields) $this->EOF =
false;
443 $this->_currentRow = -1;
445 if ($this->fetchMode == ADODB_FETCH_NUM) {
446 foreach($this->fields as $v) {
449 $this->fields = $arr;
457 $this->fields = @ifx_fetch_row($this->_queryID,
"FIRST");
458 if ($this->fields) $this->EOF =
false;
459 $this->_currentRow = 0;
461 if ($this->fetchMode == ADODB_FETCH_NUM) {
462 foreach($this->fields as $v) {
465 $this->fields = $arr;
474 $this->fields = @ifx_fetch_row($this->_queryID);
476 if (!is_array($this->fields))
return false;
478 if ($this->fetchMode == ADODB_FETCH_NUM) {
479 foreach($this->fields as $v) {
482 $this->fields = $arr;
491 return ifx_free_result($this->_queryID);
500 $itype=fmod($coltype+1,256);
501 $nullable=floor(($coltype+1) /256) ?
"N":
"Y";
502 $mtype=substr(
" CIIFFNNDN TBXCC ",$itype,1);
509 $length=floor($collength/256);
510 $precision=fmod($collength,256);
516 return array($mtype,$length,$precision,$nullable);
if(isset($_REQUEST['nrows'])) else $rs