Changeset 34 for trunk/phpgwapi/inc/adodb/drivers/adodb-informix72.inc.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/drivers/adodb-informix72.inc.php
r2 r34 1 1 <?php 2 2 /* 3 V4. 51 29 July 2004 (c) 2000-2004John Lim. All rights reserved.3 V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved. 4 4 Released under both BSD license and Lesser GPL library license. 5 5 Whenever there is any discrepancy between the two licenses, … … 29 29 var $hasAffectedRows = true; 30 30 var $substr = 'substr'; 31 var $metaTablesSQL="select tabname from systables where tabtype!=' 'and owner!='informix'"; //Don't get informix tables and pseudo-tables31 var $metaTablesSQL="select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables 32 32 33 33 … … 59 59 // alternatively, use older method: 60 60 //putenv("DBDATE=Y4MD-"); 61 61 62 62 // force ISO date format 63 63 putenv('GL_DATE=%Y-%m-%d'); … … 75 75 76 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");77 $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1"); 78 78 $this->version = $arr; 79 79 return $arr; … … 124 124 } 125 125 126 function RowLock($tables,$where )126 function RowLock($tables,$where,$flds='1 as ignore') 127 127 { 128 128 if ($this->_autocommit) $this->BeginTrans(); 129 return $this->GetOne("select 1 as ignorefrom $tables where $where for update");129 return $this->GetOne("select $flds from $tables where $where for update"); 130 130 } 131 131 … … 142 142 function ErrorNo() 143 143 { 144 preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); //!EOS144 preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); 145 145 if (is_array($parse) && isset($parse[1])) return (int)$parse[1]; 146 146 return 0; … … 152 152 global $ADODB_FETCH_MODE; 153 153 154 $false = false; 154 155 if (!empty($this->metaColumnsSQL)) { 155 156 $save = $ADODB_FETCH_MODE; … … 159 160 if (isset($savem)) $this->SetFetchMode($savem); 160 161 $ADODB_FETCH_MODE = $save; 161 if ($rs === false) return false;162 if ($rs === false) return $false; 162 163 $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items 163 164 … … 166 167 $fld = new ADOFieldObject(); 167 168 $fld->name = $rs->fields[0]; 169 /* //!eos. 170 $rs->fields[1] is not the correct adodb type 171 $rs->fields[2] is not correct max_length, because can include not-null bit 172 168 173 $fld->type = $rs->fields[1]; 169 174 $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag 170 $fld->max_length = $rs->fields[2]; 175 $fld->max_length = $rs->fields[2];*/ 176 $pr=ifx_props($rs->fields[1],$rs->fields[2]); //!eos 177 $fld->type = $pr[0] ;//!eos 178 $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); 179 $fld->max_length = $pr[1]; //!eos 180 $fld->precision = $pr[2] ;//!eos 181 $fld->not_null = $pr[3]=="N"; //!eos 182 171 183 if (trim($rs->fields[3]) != "AAAAAA 0") { 172 184 $fld->has_default = 1; … … 181 193 182 194 $rs->Close(); 195 $rspkey->Close(); //!eos 183 196 return $retarr; 184 197 } 185 198 186 return false;199 return $false; 187 200 } 188 201 … … 191 204 return ADOConnection::MetaColumns($table,false); 192 205 } 206 207 function MetaForeignKeys($table, $owner=false, $upper=false) //!Eos 208 { 209 $sql = " 210 select tr.tabname,updrule,delrule, 211 i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4, 212 i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8 213 from systables t,sysconstraints s,sysindexes i, 214 sysreferences r,systables tr,sysconstraints s2,sysindexes i2 215 where t.tabname='$table' 216 and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid 217 and i.idxname=s.idxname and tr.tabid=r.ptabid 218 and s2.constrid=r.primary and i2.idxname=s2.idxname"; 219 220 $rs = $this->Execute($sql); 221 if (!$rs || $rs->EOF) return false; 222 $arr =& $rs->GetArray(); 223 $a = array(); 224 foreach($arr as $v) { 225 $coldest=$this->metaColumnNames($v["tabname"]); 226 $colorig=$this->metaColumnNames($table); 227 $colnames=array(); 228 for($i=1;$i<=8 && $v["o$i"] ;$i++) { 229 $colnames[]=$coldest[$v["d$i"]-1]."=".$colorig[$v["o$i"]-1]; 230 } 231 if($upper) 232 $a[strtoupper($v["tabname"])] = $colnames; 233 else 234 $a[$v["tabname"]] = $colnames; 235 } 236 return $a; 237 } 193 238 194 239 function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB') … … 332 377 } 333 378 } 334 return $this->_fieldprops[$fieldOffset]; 379 $ret = $this->_fieldprops[$fieldOffset]; 380 return $ret; 335 381 } 336 382 … … 343 389 function _seek($row) 344 390 { 345 return @ifx_fetch_row($this->_queryID, $row);391 return @ifx_fetch_row($this->_queryID, (int) $row); 346 392 } 347 393 … … 402 448 403 449 } 450 /** !Eos 451 * Auxiliar function to Parse coltype,collength. Used by Metacolumns 452 * return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties) 453 */ 454 function ifx_props($coltype,$collength){ 455 $itype=fmod($coltype+1,256); 456 $nullable=floor(($coltype+1) /256) ?"N":"Y"; 457 $mtype=substr(" CIIFFNNDN TBXCC ",$itype,1); 458 switch ($itype){ 459 case 2: 460 $length=4; 461 case 6: 462 case 9: 463 case 14: 464 $length=floor($collength/256); 465 $precision=fmod($collength,256); 466 break; 467 default: 468 $precision=0; 469 $length=$collength; 470 } 471 return array($mtype,$length,$precision,$nullable); 472 } 473 474 404 475 ?>
Note: See TracChangeset
for help on using the changeset viewer.