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-oci8.inc.php

    r2 r34  
    22/* 
    33 
    4   version V4.50 6 July 2004 (c) 2000-2004 John Lim. All rights reserved. 
     4  version V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved. 
    55 
    66  Released under both BSD license and Lesser GPL library license.  
     
    6464        var $_commit = OCI_COMMIT_ON_SUCCESS; 
    6565        var $_initdate = true; // init date to YYYY-MM-DD 
    66         var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')"; 
     66        var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW') and table_name not like 'BIN\$%'"; // bin$ tables are recycle bin tables 
    6767        var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net 
    6868        var $_bindInputArray = true; 
     
    7676        var $connectSID = false; 
    7777        var $_bind = false; 
     78        var $_nestedSQL = true; 
    7879        var $_hasOCIFetchStatement = false; 
    7980        var $_getarray = false; // currently not working 
     
    8384        var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit. 
    8485        var $NLS_DATE_FORMAT = 'YYYY-MM-DD';  // To include time, use 'RRRR-MM-DD HH24:MI:SS' 
     86        var $dateformat = 'YYYY-MM-DD'; // for DBDate() 
    8587        var $useDBDateFormatForTextInput=false; 
    8688        var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true) 
     
    100102        global $ADODB_FETCH_MODE; 
    101103         
     104                $false = false; 
    102105                $save = $ADODB_FETCH_MODE; 
    103106                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     
    108111                if (isset($savem)) $this->SetFetchMode($savem); 
    109112                $ADODB_FETCH_MODE = $save; 
    110                 if (!$rs) return false; 
     113                if (!$rs) { 
     114                        return $false; 
     115                } 
    111116                $retarr = array(); 
    112117                while (!$rs->EOF) { //print_r($rs->fields); 
     
    116121                        $fld->max_length = $rs->fields[2]; 
    117122                        $fld->scale = $rs->fields[3]; 
    118                         if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) { 
    119                                 $fld->type ='INT'; 
     123                        if ($rs->fields[1] == 'NUMBER') { 
     124                                if ($rs->fields[3] == 0) $fld->type = 'INT'; 
    120125                        $fld->max_length = $rs->fields[4]; 
    121126                }        
     
    129134                } 
    130135                $rs->Close(); 
    131                 return $retarr; 
     136                if (empty($retarr)) 
     137                        return  $false; 
     138                else  
     139                        return $retarr; 
    132140        } 
    133141         
     
    190198                                        $argHostport=$argHostinfo[1]; 
    191199                                } else { 
    192                                         $argHostport="1521"; 
     200                                        $argHostport = empty($this->port)?  "1521" : $this->port; 
    193201                                } 
    194202                                 
     
    204212                //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; 
    205213                if ($mode==1) { 
    206                         $this->_connectionID = OCIPLogon($argUsername,$argPassword, $argDatabasename); 
     214                        $this->_connectionID = ($this->charSet) ?  
     215                                OCIPLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) 
     216                                : 
     217                                OCIPLogon($argUsername,$argPassword, $argDatabasename) 
     218                                ; 
    207219                        if ($this->_connectionID && $this->autoRollback)  OCIrollback($this->_connectionID); 
    208220                } else if ($mode==2) { 
    209                         $this->_connectionID = OCINLogon($argUsername,$argPassword, $argDatabasename); 
     221                        $this->_connectionID = ($this->charSet) ?  
     222                                OCINLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) 
     223                                : 
     224                                OCINLogon($argUsername,$argPassword, $argDatabasename); 
     225                                 
    210226                } else { 
    211                         $this->_connectionID = OCILogon($argUsername,$argPassword, $argDatabasename); 
    212                 } 
    213                 if ($this->_connectionID === false) return false; 
     227                        $this->_connectionID = ($this->charSet) ?  
     228                                OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet) 
     229                                : 
     230                                OCILogon($argUsername,$argPassword, $argDatabasename); 
     231                } 
     232                if (!$this->_connectionID) return false; 
    214233                if ($this->_initdate) { 
    215234                        $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); 
     
    259278                 
    260279                if (is_string($d)) $d = ADORecordSet::UnixDate($d); 
    261                 return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->NLS_DATE_FORMAT."')"; 
    262         } 
    263  
     280                return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->dateformat."')"; 
     281        } 
     282 
     283        function BindDate($d) 
     284        { 
     285                $d = ADOConnection::DBDate($d); 
     286                if (strncmp($d,"'",1)) return $d; 
     287                 
     288                return substr($d,1,strlen($d)-2); 
     289        } 
     290         
     291        function BindTimeStamp($d) 
     292        { 
     293                $d = ADOConnection::DBTimeStamp($d); 
     294                if (strncmp($d,"'",1)) return $d; 
     295                 
     296                return substr($d,1,strlen($d)-2); 
     297        } 
    264298         
    265299        // format and return date string in database timestamp format 
     
    268302                if (empty($ts) && $ts !== 0) return 'null'; 
    269303                if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); 
    270                 return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; 
    271         } 
    272          
    273         function RowLock($tables,$where)  
     304                return 'TO_DATE('.adodb_date("'Y-m-d H:i:s'",$ts).",'RRRR-MM-DD, HH24:MI:SS')"; 
     305        } 
     306         
     307        function RowLock($tables,$where,$flds='1 as ignore')  
    274308        { 
    275309                if ($this->autoCommit) $this->BeginTrans(); 
    276                 return $this->GetOne("select 1 as ignore from $tables where $where for update"); 
     310                return $this->GetOne("select $flds from $tables where $where for update"); 
    277311        } 
    278312         
     
    282316                        $save = $this->metaTablesSQL; 
    283317                        $mask = $this->qstr(strtoupper($mask)); 
    284                         $this->metaTablesSQL .= " AND table_name like $mask"; 
     318                        $this->metaTablesSQL .= " AND upper(table_name) like $mask"; 
    285319                } 
    286320                $ret =& ADOConnection::MetaTables($ttype,$showSchema); 
     
    290324                } 
    291325                return $ret; 
     326        } 
     327         
     328        // Mark Newnham  
     329        function &MetaIndexes ($table, $primary = FALSE, $owner=false) 
     330        { 
     331        // save old fetch mode 
     332        global $ADODB_FETCH_MODE; 
     333 
     334        $save = $ADODB_FETCH_MODE; 
     335        $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     336 
     337        if ($this->fetchMode !== FALSE) { 
     338               $savem = $this->SetFetchMode(FALSE); 
     339        } 
     340 
     341                // get index details 
     342                $table = strtoupper($table); 
     343 
     344                // get Primary index 
     345                $primary_key = ''; 
     346 
     347                $false = false; 
     348                $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table)); 
     349                if ($row = $rs->FetchRow()) 
     350                   $primary_key = $row[1]; //constraint_name 
     351 
     352                if ($primary==TRUE && $primary_key=='') { 
     353                         if (isset($savem))  
     354                $this->SetFetchMode($savem); 
     355                        $ADODB_FETCH_MODE = $save; 
     356                        return $false; //There is no primary key 
     357                } 
     358 
     359        $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); 
     360 
     361                 
     362        if (!is_object($rs)) { 
     363                        if (isset($savem))  
     364                                $this->SetFetchMode($savem); 
     365                        $ADODB_FETCH_MODE = $save; 
     366            return $false; 
     367        } 
     368 
     369                $indexes = array (); 
     370        // parse index data into array 
     371 
     372        while ($row = $rs->FetchRow()) { 
     373                        if ($primary && $row[0] != $primary_key) continue; 
     374            if (!isset($indexes[$row[0]])) { 
     375                                $indexes[$row[0]] = array( 
     376                                   'unique' => ($row[1] == 'UNIQUE'), 
     377                                   'columns' => array() 
     378                                ); 
     379            } 
     380            $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; 
     381        } 
     382 
     383        // sort columns by order in the index 
     384        foreach ( array_keys ($indexes) as $index ) { 
     385            ksort ($indexes[$index]['columns']); 
     386        } 
     387 
     388                if (isset($savem)) {  
     389            $this->SetFetchMode($savem); 
     390                        $ADODB_FETCH_MODE = $save; 
     391                } 
     392        return $indexes; 
    292393        } 
    293394         
     
    298399                $this->autoCommit = false; 
    299400                $this->_commit = OCI_DEFAULT; 
     401                 
     402                if ($this->_transmode) $this->Execute("SET TRANSACTION ".$this->_transmode); 
    300403                return true; 
    301404        } 
     
    333436                if ($this->_errorMsg !== false) return $this->_errorMsg; 
    334437 
    335                 if (is_resource($this->_stmt)) $arr = @OCIerror($this->_stmt); 
     438                if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); 
    336439                if (empty($arr)) { 
    337                         $arr = @OCIerror($this->_connectionID); 
    338                         if ($arr === false) $arr = @OCIError(); 
     440                        if (is_resource($this->_connectionID)) $arr = @OCIError($this->_connectionID); 
     441                        else $arr = @OCIError(); 
    339442                        if ($arr === false) return ''; 
    340443                } 
     
    413516                                break; 
    414517                                 
     518                        case 'w': 
     519                                $s .= 'D'; 
     520                                break; 
     521                                 
     522                        case 'l': 
     523                                $s .= 'DAY'; 
     524                                break; 
     525                                 
     526                         case 'W': 
     527                                $s .= 'WW'; 
     528                                break; 
     529                                 
    415530                        default: 
    416531                        // handle escape characters... 
     
    458573                                //$inputarr['adodb_rownum'] = $nrows; 
    459574                                if ($this->databaseType == 'oci8po') { 
    460                                         $sql = "select * from ($sql) where rownum <= ?"; 
     575                                        $sql = "select * from (".$sql.") where rownum <= ?"; 
    461576                                } else { 
    462                                         $sql = "select * from ($sql) where rownum <= :adodb_offset"; 
     577                                        $sql = "select * from (".$sql.") where rownum <= :adodb_offset"; 
    463578                                }  
    464579                                $inputarr['adodb_offset'] = $nrows; 
     
    474589                         
    475590                         // Let Oracle return the name of the columns 
    476                          $q_fields = "SELECT * FROM ($sql) WHERE NULL = NULL"; 
    477                          if (!$stmt = OCIParse($this->_connectionID, $q_fields)) { 
    478                                  return false; 
    479                          } 
     591                        $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL"; 
     592                          
     593                        $false = false; 
     594                        if (! $stmt_arr = $this->Prepare($q_fields)) { 
     595                                return $false; 
     596                        } 
     597                        $stmt = $stmt_arr[1]; 
    480598                          
    481599                         if (is_array($inputarr)) { 
     
    500618                         if (!OCIExecute($stmt, OCI_DEFAULT)) { 
    501619                                 OCIFreeStatement($stmt);  
    502                                  return false; 
     620                                 return $false; 
    503621                         } 
    504622                          
     
    615733        } 
    616734 
     735                /** 
     736         * Execute SQL  
     737         * 
     738         * @param sql           SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) 
     739         * @param [inputarr]    holds the input data to bind to. Null elements will be set to null. 
     740         * @return              RecordSet or false 
     741         */ 
     742        function &Execute($sql,$inputarr=false)  
     743        { 
     744                if ($this->fnExecute) { 
     745                        $fn = $this->fnExecute; 
     746                        $ret =& $fn($this,$sql,$inputarr); 
     747                        if (isset($ret)) return $ret; 
     748                } 
     749                if ($inputarr) { 
     750                        #if (!is_array($inputarr)) $inputarr = array($inputarr); 
     751                         
     752                        $element0 = reset($inputarr); 
     753                         
     754                        # is_object check because oci8 descriptors can be passed in 
     755                        if (is_array($element0) && !is_object(reset($element0))) { 
     756                                if (is_string($sql)) 
     757                                        $stmt = $this->Prepare($sql); 
     758                                else 
     759                                        $stmt = $sql; 
     760                                         
     761                                foreach($inputarr as $arr) { 
     762                                        $ret =& $this->_Execute($stmt,$arr); 
     763                                        if (!$ret) return $ret; 
     764                                } 
     765                        } else { 
     766                                $ret =& $this->_Execute($sql,$inputarr); 
     767                        } 
     768                         
     769                } else { 
     770                        $ret =& $this->_Execute($sql,false); 
     771                } 
     772 
     773                return $ret; 
     774        } 
    617775         
    618776        /* 
     
    627785                $stmt = OCIParse($this->_connectionID,$sql); 
    628786 
    629                 if (!$stmt) return false; 
    630  
     787                if (!$stmt) { 
     788                        $this->_errorMsg = false; 
     789                        $this->_errorCode = false; 
     790                        $arr = @OCIError($this->_connectionID); 
     791                        if ($arr === false) return false; 
     792                 
     793                        $this->_errorMsg = $arr['message']; 
     794                        $this->_errorCode = $arr['code']; 
     795                        return false; 
     796                } 
     797                 
    631798                $BINDNUM += 1; 
    632799                 
    633                 if (@OCIStatementType($stmt) == 'BEGIN') { 
     800                $sttype = @OCIStatementType($stmt); 
     801                if ($sttype == 'BEGIN' || $sttype == 'DECLARE') { 
    634802                        return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false); 
    635                 }  
    636                  
     803                } 
    637804                return array($sql,$stmt,0,$BINDNUM); 
    638805        } 
    639806         
    640807        /* 
    641                 Call an oracle stored procedure and return a cursor variable.  
    642                 Convert the cursor variable into a recordset.  
     808                Call an oracle stored procedure and returns a cursor variable as a recordset.  
    643809                Concept by Robert Tuttle robert@ud.com 
    644810                 
     
    655821        function &ExecuteCursor($sql,$cursorName='rs',$params=false) 
    656822        { 
    657                 $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor 
    658                          
     823                if (is_array($sql)) $stmt = $sql; 
     824                else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor 
     825         
    659826                if (is_array($stmt) && sizeof($stmt) >= 5) { 
     827                        $hasref = true; 
     828                        $ignoreCur = false; 
    660829                        $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); 
    661830                        if ($params) { 
     
    664833                                } 
    665834                        } 
    666                 } 
    667                 return $this->Execute($stmt); 
     835                } else 
     836                        $hasref = false; 
     837                         
     838                $rs =& $this->Execute($stmt); 
     839                if ($rs) { 
     840                        if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]); 
     841                        else if ($hasref) $rs->_refcursor = $stmt[4]; 
     842                } 
     843                return $rs; 
    668844        } 
    669845         
     
    716892                        } 
    717893            //we have to create a new Descriptor here 
    718                         $numlob = count($this -> _refLOBs); 
    719                 $this -> _refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); 
    720                         $this -> _refLOBs[$numlob]['TYPE'] = $isOutput; 
    721                          
    722                         $tmp = &$this -> _refLOBs[$numlob]['LOB']; 
     894                        $numlob = count($this->_refLOBs); 
     895                $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); 
     896                        $this->_refLOBs[$numlob]['TYPE'] = $isOutput; 
     897                         
     898                        $tmp = &$this->_refLOBs[$numlob]['LOB']; 
    723899                $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); 
    724900                        if ($this->debug) { 
    725                                 ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var binded"); 
     901                                ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var (".$name.") binded"); 
    726902                        } 
    727903                         
    728904                        // if type is input then write data to lob now 
    729905                        if ($isOutput == false) { 
    730                                 $var = $this -> BlobEncode($var); 
    731                                 $tmp -> WriteTemporary($var); 
     906                                $var = $this->BlobEncode($var); 
     907                                $tmp->WriteTemporary($var); 
     908                                $this->_refLOBs[$numlob]['VAR'] = &$var; 
    732909                                if ($this->debug) { 
    733910                                        ADOConnection::outp("<b>Bind</b>: LOB has been written to temp"); 
    734911                                } 
    735912                        } else { 
    736                                 $this -> _refLOBs[$numlob]['VAR'] = &$var; 
     913                                $this->_refLOBs[$numlob]['VAR'] = &$var; 
    737914                        } 
    738915                        $rez = $tmp; 
     
    791968            
    792969           4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); 
    793                   $db->$bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);  
     970                  $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);  
    794971                  $db->execute($stmt); 
    795972        */  
    796973        function _query($sql,$inputarr) 
    797974        { 
    798                  
    799975                if (is_array($sql)) { // is prepared sql 
    800976                        $stmt = $sql[1]; 
     
    812988                                        foreach($inputarr as $k => $v) { 
    813989                                                $bindarr[$k] = $v; 
    814                                                 OCIBindByName($stmt,":$k",$bindarr[$k],4000); 
     990                                                OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000); 
    815991                                        } 
    816992                                        $this->_bind[$bindpos] = &$bindarr; 
     
    8611037                                                //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; 
    8621038                                                $this -> _refLOBs[$key]['VAR'] = $tmp; 
    863                                         } 
    864                                         $this -> _refLOBs[$key]['LOB'] -> free(); 
    865                                         unset($this -> _refLOBs[$key]); 
     1039                                        } else { 
     1040                        $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); 
     1041                                                $this -> _refLOBs[$key]['LOB']->free(); 
     1042                                                unset($this -> _refLOBs[$key]); 
     1043                        if ($this->debug) { 
     1044                                                        ADOConnection::outp("<b>IN LOB</b>: LOB has been saved. <br>"); 
     1045                                                } 
     1046                    }                                    
    8661047                                } 
    8671048                        } 
     
    8701051                case "SELECT": 
    8711052                                        return $stmt; 
    872                                          
     1053                                 
     1054                                case 'DECLARE': 
    8731055                case "BEGIN": 
    8741056                    if (is_array($sql) && !empty($sql[4])) { 
     
    9011083                 
    9021084                if (!$this->autoCommit) OCIRollback($this->_connectionID); 
    903                 if (count($this -> _refLOBs) > 0) { 
    904                         foreach ($this -> _refLOBs as $key => $value) { 
    905                                 $this -> _refLOBs[$key] -> free(); 
    906                                 unset($this -> _refLOBs[$key]); 
     1085                if (count($this->_refLOBs) > 0) { 
     1086                        foreach ($this ->_refLOBs as $key => $value) { 
     1087                                $this->_refLOBs[$key]['LOB']->free(); 
     1088                                unset($this->_refLOBs[$key]); 
    9071089                        } 
    9081090                } 
     
    10101192        function qstr($s,$magic_quotes=false) 
    10111193        {        
    1012         $nofixquotes=false; 
     1194                //$nofixquotes=false; 
    10131195         
    10141196                if ($this->noNullStrings && strlen($s)==0)$s = ' '; 
     
    10391221        var $bind=false; 
    10401222        var $_fieldobjs; 
     1223         
    10411224        //var $_arr = false; 
    10421225                 
     
    10491232                switch ($mode) 
    10501233                { 
    1051                 default: 
    1052                 case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    10531234                case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    10541235                case ADODB_FETCH_DEFAULT: 
    10551236                case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    1056                 } 
    1057  
     1237                case ADODB_FETCH_NUM:  
     1238                default: 
     1239                $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
     1240                } 
     1241                 
     1242                $this->adodbFetchMode = $mode; 
    10581243                $this->_queryID = $queryID; 
    10591244        } 
     
    11591344        } 
    11601345         
     1346        /* 
     1347        # does not work as first record is retrieved in _initrs(), so is not included in GetArray() 
     1348        function &GetArray($nRows = -1)  
     1349        { 
     1350        global $ADODB_OCI8_GETARRAY; 
     1351         
     1352                if (true ||  !empty($ADODB_OCI8_GETARRAY)) { 
     1353                        # does not support $ADODB_ANSI_PADDING_OFF 
     1354         
     1355                        //OCI_RETURN_NULLS and OCI_RETURN_LOBS is set by OCIfetchstatement 
     1356                        switch($this->adodbFetchMode) { 
     1357                        case ADODB_FETCH_NUM: 
     1358                         
     1359                                $ncols = @OCIfetchstatement($this->_queryID, $results, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM); 
     1360                                $results = array_merge(array($this->fields),$results); 
     1361                                return $results; 
     1362                                 
     1363                        case ADODB_FETCH_ASSOC:  
     1364                                if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break; 
     1365                                 
     1366                                $ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW); 
     1367                                $results =& array_merge(array($this->fields),$assoc); 
     1368                                return $results; 
     1369                         
     1370                        default: 
     1371                                break; 
     1372                        } 
     1373                } 
     1374                         
     1375                $results =& ADORecordSet::GetArray($nRows); 
     1376                return $results; 
     1377                 
     1378        } */ 
    11611379         
    11621380        /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ 
     
    11671385                        return $arr; 
    11681386                } 
     1387                $arr = array(); 
    11691388                for ($i=1; $i < $offset; $i++)  
    1170                         if (!@OCIFetch($this->_queryID)) return array(); 
    1171                          
    1172                 if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array(); 
     1389                        if (!@OCIFetch($this->_queryID)) return $arr; 
     1390                         
     1391                if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return $arr;; 
    11731392                $results = array(); 
    11741393                $cnt = 0; 
     
    12141433        { 
    12151434                if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false; 
    1216                 OCIFreeStatement($this->_queryID); 
     1435                if (!empty($this->_refcursor)) { 
     1436                        OCIFreeCursor($this->_refcursor); 
     1437                        $this->_refcursor = false; 
     1438                } 
     1439                @OCIFreeStatement($this->_queryID); 
    12171440                $this->_queryID = false; 
    12181441                 
     
    12731496                switch ($mode) 
    12741497                { 
    1275                 default: 
    1276                 case ADODB_FETCH_NUM: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    12771498                case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    12781499                case ADODB_FETCH_DEFAULT: 
    12791500                case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
    1280                 } 
    1281  
     1501                case ADODB_FETCH_NUM:  
     1502                default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; 
     1503                } 
     1504                $this->adodbFetchMode = $mode; 
    12821505                $this->_queryID = $queryID; 
    12831506        } 
Note: See TracChangeset for help on using the changeset viewer.