Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/drivers/adodb-informix72.inc.php

    r2 r34  
    11<?php 
    22/* 
    3 V4.51 29 July 2004  (c) 2000-2004 John Lim. All rights reserved. 
     3V4.94 23 Jan 2007  (c) 2000-2007 John Lim. All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license. 
    55  Whenever there is any discrepancy between the two licenses, 
     
    2929        var $hasAffectedRows = true; 
    3030    var $substr = 'substr'; 
    31         var $metaTablesSQL="select tabname from systables where tabtype!=' ' and owner!='informix'"; //Don't get informix tables and pseudo-tables 
     31        var $metaTablesSQL="select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables 
    3232 
    3333 
     
    5959                // alternatively, use older method: 
    6060                //putenv("DBDATE=Y4MD-"); 
    61  
     61                 
    6262                // force ISO date format 
    6363                putenv('GL_DATE=%Y-%m-%d'); 
     
    7575         
    7676            $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"); 
    7878            $this->version = $arr; 
    7979            return $arr; 
     
    124124        } 
    125125 
    126         function RowLock($tables,$where) 
     126        function RowLock($tables,$where,$flds='1 as ignore') 
    127127        { 
    128128                if ($this->_autocommit) $this->BeginTrans(); 
    129                 return $this->GetOne("select 1 as ignore from $tables where $where for update"); 
     129                return $this->GetOne("select $flds from $tables where $where for update"); 
    130130        } 
    131131 
     
    142142        function ErrorNo() 
    143143        { 
    144                 preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); //!EOS 
     144                preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); 
    145145                if (is_array($parse) && isset($parse[1])) return (int)$parse[1];  
    146146                return 0; 
     
    152152        global $ADODB_FETCH_MODE; 
    153153         
     154                $false = false; 
    154155                if (!empty($this->metaColumnsSQL)) { 
    155156                        $save = $ADODB_FETCH_MODE; 
     
    159160                        if (isset($savem)) $this->SetFetchMode($savem); 
    160161                        $ADODB_FETCH_MODE = $save; 
    161                         if ($rs === false) return false; 
     162                        if ($rs === false) return $false; 
    162163                        $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items 
    163164 
     
    166167                                $fld = new ADOFieldObject(); 
    167168                                $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 
    168173                                $fld->type = $rs->fields[1]; 
    169174                                $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 
    171183                                if (trim($rs->fields[3]) != "AAAAAA 0") { 
    172184                                        $fld->has_default = 1; 
     
    181193 
    182194                        $rs->Close(); 
     195                        $rspkey->Close(); //!eos 
    183196                        return $retarr;  
    184197                } 
    185198 
    186                 return false; 
     199                return $false; 
    187200        } 
    188201         
     
    191204                return ADOConnection::MetaColumns($table,false); 
    192205   } 
     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         } 
    193238 
    194239   function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB') 
     
    332377                        } 
    333378                } 
    334                 return $this->_fieldprops[$fieldOffset]; 
     379                $ret = $this->_fieldprops[$fieldOffset]; 
     380                return $ret; 
    335381        } 
    336382 
     
    343389        function _seek($row) 
    344390        { 
    345                 return @ifx_fetch_row($this->_queryID, $row); 
     391                return @ifx_fetch_row($this->_queryID, (int) $row); 
    346392        } 
    347393 
     
    402448 
    403449} 
     450/** !Eos 
     451* Auxiliar function to Parse coltype,collength. Used by Metacolumns 
     452* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties) 
     453*/ 
     454function 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 
    404475?> 
Note: See TracChangeset for help on using the changeset viewer.