source: trunk/phpgwapi/inc/adodb/drivers/adodb-odbc.inc.php @ 2

Revision 2, 18.9 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2/*
3V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved.
4  Released under both BSD license and Lesser GPL library license.
5  Whenever there is any discrepancy between the two licenses,
6  the BSD license will take precedence.
7Set tabs to 4 for best viewing.
8 
9  Latest version is available at http://adodb.sourceforge.net
10 
11  Requires ODBC. Works on Windows and Unix.
12*/
13// security - hide paths
14if (!defined('ADODB_DIR')) die();
15
16  define("_ADODB_ODBC_LAYER", 2 );
17         
18/*--------------------------------------------------------------------------------------
19--------------------------------------------------------------------------------------*/
20
21
22class ADODB_odbc extends ADOConnection {
23        var $databaseType = "odbc";     
24        var $fmtDate = "'Y-m-d'";
25        var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
26        var $replaceQuote = "''"; // string to use to replace quotes
27        var $dataProvider = "odbc";
28        var $hasAffectedRows = true;
29        var $binmode = ODBC_BINMODE_RETURN;
30        var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive
31                                                                // breaking backward-compat
32        //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
33        var $_bindInputArray = false;   
34        var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
35        var $_genSeqSQL = "create table %s (id integer)";
36        var $_autocommit = true;
37        var $_haserrorfunctions = true;
38        var $_has_stupid_odbc_fetch_api_change = true;
39        var $_lastAffectedRows = 0;
40        var $uCaseTables = true; // for meta* functions, uppercase table names
41       
42        function ADODB_odbc()
43        {       
44                $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
45                $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
46        }
47       
48        function ServerInfo()
49        {
50       
51                if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
52                        $dsn = strtoupper($this->host);
53                        $first = true;
54                        $found = false;
55                       
56                        if (!function_exists('odbc_data_source')) return false;
57                       
58                        while(true) {
59                               
60                                $rez = @odbc_data_source($this->_connectionID,
61                                        $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
62                                $first = false;
63                                if (!is_array($rez)) break;
64                                if (strtoupper($rez['server']) == $dsn) {
65                                        $found = true;
66                                        break;
67                                }
68                        }
69                        if (!$found) return ADOConnection::ServerInfo();
70                        if (!isset($rez['version'])) $rez['version'] = '';
71                        return $rez;
72                } else {
73                        return ADOConnection::ServerInfo();
74                }
75        }
76
77       
78        function CreateSequence($seqname='adodbseq',$start=1)
79        {
80                if (empty($this->_genSeqSQL)) return false;
81                $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
82                if (!$ok) return false;
83                $start -= 1;
84                return $this->Execute("insert into $seqname values($start)");
85        }
86       
87        var $_dropSeqSQL = 'drop table %s';
88        function DropSequence($seqname)
89        {
90                if (empty($this->_dropSeqSQL)) return false;
91                return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
92        }
93       
94        /*
95                This algorithm is not very efficient, but works even if table locking
96                is not available.
97               
98                Will return false if unable to generate an ID after $MAXLOOPS attempts.
99        */
100        function GenID($seq='adodbseq',$start=1)
101        {       
102                // if you have to modify the parameter below, your database is overloaded,
103                // or you need to implement generation of id's yourself!
104                $MAXLOOPS = 100;
105                //$this->debug=1;
106                while (--$MAXLOOPS>=0) {
107                        $num = $this->GetOne("select id from $seq");
108                        if ($num === false) {
109                                $this->Execute(sprintf($this->_genSeqSQL ,$seq));       
110                                $start -= 1;
111                                $num = '0';
112                                $ok = $this->Execute("insert into $seq values($start)");
113                                if (!$ok) return false;
114                        }
115                        $this->Execute("update $seq set id=id+1 where id=$num");
116                       
117                        if ($this->affected_rows() > 0) {
118                                $num += 1;
119                                $this->genID = $num;
120                                return $num;
121                        }
122                }
123                if ($fn = $this->raiseErrorFn) {
124                        $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
125                }
126                return false;
127        }
128
129
130        function ErrorMsg()
131        {
132                if ($this->_haserrorfunctions) {
133                        if ($this->_errorMsg !== false) return $this->_errorMsg;
134                        if (empty($this->_connectionID)) return @odbc_errormsg();
135                        return @odbc_errormsg($this->_connectionID);
136                } else return ADOConnection::ErrorMsg();
137        }
138       
139        function ErrorNo()
140        {
141               
142                if ($this->_haserrorfunctions) {
143                        if ($this->_errorCode !== false) {
144                                // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
145                                return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode;
146                        }
147
148                        if (empty($this->_connectionID)) $e = @odbc_error();
149                        else $e = @odbc_error($this->_connectionID);
150                       
151                         // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
152                         // so we check and patch
153                        if (strlen($e)<=2) return 0;
154                        return $e;
155                } else return ADOConnection::ErrorNo();
156        }
157       
158       
159        // returns true or false
160        function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
161        {
162        global $php_errormsg;
163               
164                if (!function_exists('odbc_connect')) return null;
165               
166                if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
167                        ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
168                }
169                if (isset($php_errormsg)) $php_errormsg = '';
170                if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
171                else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
172                $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
173                if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
174               
175                //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
176                return $this->_connectionID != false;
177        }
178       
179        // returns true or false
180        function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
181        {
182        global $php_errormsg;
183       
184                if (!function_exists('odbc_connect')) return null;
185               
186                if (isset($php_errormsg)) $php_errormsg = '';
187                $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
188                if ($this->debug && $argDatabasename) {
189                        ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
190                }
191        //      print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
192                if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
193                else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
194               
195                $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
196                if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
197                if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
198               
199                return $this->_connectionID != false;
200        }
201
202        function BeginTrans()
203        {       
204                if (!$this->hasTransactions) return false;
205                if ($this->transOff) return true;
206                $this->transCnt += 1;
207                $this->_autocommit = false;
208                return odbc_autocommit($this->_connectionID,false);
209        }
210       
211        function CommitTrans($ok=true)
212        {
213                if ($this->transOff) return true;
214                if (!$ok) return $this->RollbackTrans();
215                if ($this->transCnt) $this->transCnt -= 1;
216                $this->_autocommit = true;
217                $ret = odbc_commit($this->_connectionID);
218                odbc_autocommit($this->_connectionID,true);
219                return $ret;
220        }
221       
222        function RollbackTrans()
223        {
224                if ($this->transOff) return true;
225                if ($this->transCnt) $this->transCnt -= 1;
226                $this->_autocommit = true;
227                $ret = odbc_rollback($this->_connectionID);
228                odbc_autocommit($this->_connectionID,true);
229                return $ret;
230        }
231       
232        function MetaPrimaryKeys($table)
233        {
234        global $ADODB_FETCH_MODE;
235       
236                if ($this->uCaseTables) $table = strtoupper($table);
237                $schema = '';
238                $this->_findschema($table,$schema);
239
240                $savem = $ADODB_FETCH_MODE;
241                $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
242                $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);
243               
244                if (!$qid) {
245                        $ADODB_FETCH_MODE = $savem;
246                        return false;
247                }
248                $rs = new ADORecordSet_odbc($qid);
249                $ADODB_FETCH_MODE = $savem;
250               
251                if (!$rs) return false;
252                $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
253               
254                $arr =& $rs->GetArray();
255                $rs->Close();
256                //print_r($arr);
257                $arr2 = array();
258                for ($i=0; $i < sizeof($arr); $i++) {
259                        if ($arr[$i][3]) $arr2[] = $arr[$i][3];
260                }
261                return $arr2;
262        }
263       
264       
265       
266        function &MetaTables($ttype=false)
267        {
268        global $ADODB_FETCH_MODE;
269       
270                $savem = $ADODB_FETCH_MODE;
271                $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
272                $qid = odbc_tables($this->_connectionID);
273               
274                $rs = new ADORecordSet_odbc($qid);
275               
276                $ADODB_FETCH_MODE = $savem;
277                if (!$rs) return false;
278               
279                $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
280               
281                $arr =& $rs->GetArray();
282                //print_r($arr);
283               
284                $rs->Close();
285                $arr2 = array();
286               
287                if ($ttype) {
288                        $isview = strncmp($ttype,'V',1) === 0;
289                }
290                for ($i=0; $i < sizeof($arr); $i++) {
291                        if (!$arr[$i][2]) continue;
292                        $type = $arr[$i][3];
293                        if ($ttype) {
294                                if ($isview) {
295                                        if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2];
296                                } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
297                        } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
298                }
299                return $arr2;
300        }
301       
302/*
303/ SQL data type codes /
304#define SQL_UNKNOWN_TYPE        0
305#define SQL_CHAR                        1
306#define SQL_NUMERIC              2
307#define SQL_DECIMAL              3
308#define SQL_INTEGER              4
309#define SQL_SMALLINT            5
310#define SQL_FLOAT                  6
311#define SQL_REAL                        7
312#define SQL_DOUBLE                8
313#if (ODBCVER >= 0x0300)
314#define SQL_DATETIME            9
315#endif
316#define SQL_VARCHAR             12
317
318/ One-parameter shortcuts for date/time data types /
319#if (ODBCVER >= 0x0300)
320#define SQL_TYPE_DATE     91
321#define SQL_TYPE_TIME     92
322#define SQL_TYPE_TIMESTAMP 93
323
324#define SQL_UNICODE                             (-95)
325#define SQL_UNICODE_VARCHAR                     (-96)
326#define SQL_UNICODE_LONGVARCHAR                 (-97)
327*/
328        function ODBCTypes($t)
329        {
330                switch ((integer)$t) {
331                case 1:
332                case 12:
333                case 0:
334                case -95:
335                case -96:
336                        return 'C';
337                case -97:
338                case -1: //text
339                        return 'X';
340                case -4: //image
341                        return 'B';
342                               
343                case 91:
344                case 11:
345                        return 'D';
346                       
347                case 92:
348                case 93:
349                case 9: return 'T';
350                case 4:
351                case 5:
352                case -6:
353                        return 'I';
354                       
355                case -11: // uniqidentifier
356                        return 'R';
357                case -7: //bit
358                        return 'L';
359               
360                default:
361                        return 'N';
362                }
363        }
364       
365        function &MetaColumns($table)
366        {
367        global $ADODB_FETCH_MODE;
368       
369                if ($this->uCaseTables) $table = strtoupper($table);
370                $schema = '';
371                $this->_findschema($table,$schema);
372               
373                $savem = $ADODB_FETCH_MODE;
374                $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
375       
376                /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
377                        $qid2 = odbc_tables($this->_connectionID);
378                        $rs = new ADORecordSet_odbc($qid2);             
379                        $ADODB_FETCH_MODE = $savem;
380                        if (!$rs) return false;
381                        $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
382                        $rs->_fetch();
383                       
384                        while (!$rs->EOF) {
385                                if ($table == strtoupper($rs->fields[2])) {
386                                        $q = $rs->fields[0];
387                                        $o = $rs->fields[1];
388                                        break;
389                                }
390                                $rs->MoveNext();
391                        }
392                        $rs->Close();
393                       
394                        $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
395                } */
396               
397                switch ($this->databaseType) {
398                case 'access':
399                case 'vfp':
400                        $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
401                        break;
402               
403               
404                case 'db2':
405            $colname = "%";
406            $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
407            break;
408                       
409                default:
410                        $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
411                        if (empty($qid)) $qid = odbc_columns($this->_connectionID);
412                        break;
413                }
414                if (empty($qid)) return false;
415               
416                $rs = new ADORecordSet_odbc($qid);
417                $ADODB_FETCH_MODE = $savem;
418               
419                if (!$rs) return false;
420               
421                $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
422                $rs->_fetch();
423                $retarr = array();
424               
425                /*
426                $rs->fields indices
427                0 TABLE_QUALIFIER
428                1 TABLE_SCHEM
429                2 TABLE_NAME
430                3 COLUMN_NAME
431                4 DATA_TYPE
432                5 TYPE_NAME
433                6 PRECISION
434                7 LENGTH
435                8 SCALE
436                9 RADIX
437                10 NULLABLE
438                11 REMARKS
439                */
440                while (!$rs->EOF) {
441                        //adodb_pr($rs->fields);
442                        if (strtoupper($rs->fields[2]) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
443                                $fld = new ADOFieldObject();
444                                $fld->name = $rs->fields[3];
445                                $fld->type = $this->ODBCTypes($rs->fields[4]);
446                               
447                                // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
448                                // access uses precision to store length for char/varchar
449                                if ($fld->type == 'C' or $fld->type == 'X') {
450                                        if ($this->databaseType == 'access')
451                                                $fld->max_length = $rs->fields[6];
452                                        else if ($rs->fields[4] <= -95) // UNICODE
453                                                $fld->max_length = $rs->fields[7]/2;
454                                        else
455                                                $fld->max_length = $rs->fields[7];
456                                } else
457                                        $fld->max_length = $rs->fields[7];
458                                $fld->not_null = !empty($rs->fields[10]);
459                                $fld->scale = $rs->fields[8];
460                                $retarr[strtoupper($fld->name)] = $fld;
461                        } else if (sizeof($retarr)>0)
462                                break;
463                        $rs->MoveNext();
464                }
465                $rs->Close(); //-- crashes 4.03pl1 -- why?
466               
467                return $retarr;
468        }
469       
470        function Prepare($sql)
471        {
472                if (! $this->_bindInputArray) return $sql; // no binding
473                $stmt = odbc_prepare($this->_connectionID,$sql);
474                if (!$stmt) {
475                        // we don't know whether odbc driver is parsing prepared stmts, so just return sql
476                        return $sql;
477                }
478                return array($sql,$stmt,false);
479        }
480
481        /* returns queryID or false */
482        function _query($sql,$inputarr=false)
483        {
484        GLOBAL $php_errormsg;
485                if (isset($php_errormsg)) $php_errormsg = '';
486                $this->_error = '';
487               
488                if ($inputarr) {
489                        if (is_array($sql)) {
490                                $stmtid = $sql[1];
491                        } else {
492                                $stmtid = odbc_prepare($this->_connectionID,$sql);
493       
494                                if ($stmtid == false) {
495                                        $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
496                                        return false;
497                                }
498                        }
499                       
500                        if (! odbc_execute($stmtid,$inputarr)) {
501                                //@odbc_free_result($stmtid);
502                                if ($this->_haserrorfunctions) {
503                                        $this->_errorMsg = odbc_errormsg();
504                                        $this->_errorCode = odbc_error();
505                                }
506                                return false;
507                        }
508               
509                } else if (is_array($sql)) {
510                        $stmtid = $sql[1];
511                        if (!odbc_execute($stmtid)) {
512                                //@odbc_free_result($stmtid);
513                                if ($this->_haserrorfunctions) {
514                                        $this->_errorMsg = odbc_errormsg();
515                                        $this->_errorCode = odbc_error();
516                                }
517                                return false;
518                        }
519                } else
520                        $stmtid = odbc_exec($this->_connectionID,$sql);
521               
522                $this->_lastAffectedRows = 0;
523                if ($stmtid) {
524                        if (@odbc_num_fields($stmtid) == 0) {
525                                $this->_lastAffectedRows = odbc_num_rows($stmtid);
526                                $stmtid = true;
527                        } else {
528                                $this->_lastAffectedRows = 0;
529                                odbc_binmode($stmtid,$this->binmode);
530                                odbc_longreadlen($stmtid,$this->maxblobsize);
531                        }
532                       
533                        if ($this->_haserrorfunctions) {
534                                $this->_errorMsg = '';
535                                $this->_errorCode = 0;
536                        } else
537                                $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
538                } else {
539                        if ($this->_haserrorfunctions) {
540                                $this->_errorMsg = odbc_errormsg();
541                                $this->_errorCode = odbc_error();
542                        } else
543                                $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
544                }
545                return $stmtid;
546        }
547
548        /*
549                Insert a null into the blob field of the table first.
550                Then use UpdateBlob to store the blob.
551               
552                Usage:
553                 
554                $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
555                $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
556        */
557        function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
558        {
559                return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
560        }
561       
562        // returns true or false
563        function _close()
564        {
565                $ret = @odbc_close($this->_connectionID);
566                $this->_connectionID = false;
567                return $ret;
568        }
569
570        function _affectedrows()
571        {
572                return $this->_lastAffectedRows;
573        }
574       
575}
576       
577/*--------------------------------------------------------------------------------------
578         Class Name: Recordset
579--------------------------------------------------------------------------------------*/
580
581class ADORecordSet_odbc extends ADORecordSet { 
582       
583        var $bind = false;
584        var $databaseType = "odbc";             
585        var $dataProvider = "odbc";
586        var $useFetchArray;
587        var $_has_stupid_odbc_fetch_api_change;
588       
589        function ADORecordSet_odbc($id,$mode=false)
590        {
591                if ($mode === false) { 
592                        global $ADODB_FETCH_MODE;
593                        $mode = $ADODB_FETCH_MODE;
594                }
595                $this->fetchMode = $mode;
596               
597                $this->_queryID = $id;
598               
599                // the following is required for mysql odbc driver in 4.3.1 -- why?
600                $this->EOF = false;
601                $this->_currentRow = -1;
602                //$this->ADORecordSet($id);
603        }
604
605
606        // returns the field object
607        function &FetchField($fieldOffset = -1)
608        {
609               
610                $off=$fieldOffset+1; // offsets begin at 1
611               
612                $o= new ADOFieldObject();
613                $o->name = @odbc_field_name($this->_queryID,$off);
614                $o->type = @odbc_field_type($this->_queryID,$off);
615                $o->max_length = @odbc_field_len($this->_queryID,$off);
616                if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
617                else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
618                return $o;
619        }
620       
621        /* Use associative array to get fields array */
622        function Fields($colname)
623        {
624                if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
625                if (!$this->bind) {
626                        $this->bind = array();
627                        for ($i=0; $i < $this->_numOfFields; $i++) {
628                                $o = $this->FetchField($i);
629                                $this->bind[strtoupper($o->name)] = $i;
630                        }
631                }
632
633                 return $this->fields[$this->bind[strtoupper($colname)]];
634        }
635       
636               
637        function _initrs()
638        {
639        global $ADODB_COUNTRECS;
640                $this->_numOfRows = ($ADODB_COUNTRECS) ? @odbc_num_rows($this->_queryID) : -1;
641                $this->_numOfFields = @odbc_num_fields($this->_queryID);
642                // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
643                if ($this->_numOfRows == 0) $this->_numOfRows = -1;
644                //$this->useFetchArray = $this->connection->useFetchArray;
645                $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
646        }       
647       
648        function _seek($row)
649        {
650                return false;
651        }
652       
653        // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
654        function &GetArrayLimit($nrows,$offset=-1)
655        {
656                if ($offset <= 0) {
657                        $rs =& $this->GetArray($nrows);
658                        return $rs;
659                }
660                $savem = $this->fetchMode;
661                $this->fetchMode = ADODB_FETCH_NUM;
662                $this->Move($offset);
663                $this->fetchMode = $savem;
664               
665                if ($this->fetchMode & ADODB_FETCH_ASSOC) {
666                        $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
667                }
668               
669                $results = array();
670                $cnt = 0;
671                while (!$this->EOF && $nrows != $cnt) {
672                        $results[$cnt++] = $this->fields;
673                        $this->MoveNext();
674                }
675               
676                return $results;
677        }
678       
679       
680        function MoveNext()
681        {
682                if ($this->_numOfRows != 0 && !$this->EOF) {           
683                        $this->_currentRow++;
684                        $row = 0;
685                        if ($this->_has_stupid_odbc_fetch_api_change)
686                                $rez = @odbc_fetch_into($this->_queryID,$this->fields);
687                        else
688                                $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
689                        if ($rez) {
690                                if ($this->fetchMode & ADODB_FETCH_ASSOC) {
691                                        $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
692                                }
693                                return true;
694                        }
695                }
696                $this->fields = false;
697                $this->EOF = true;
698                return false;
699        }       
700       
701        function _fetch()
702        {
703                $row = 0;
704                if ($this->_has_stupid_odbc_fetch_api_change)
705                        $rez = @odbc_fetch_into($this->_queryID,$this->fields,$row);
706                else
707                        $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
708               
709                if ($rez) {
710                        if ($this->fetchMode & ADODB_FETCH_ASSOC) {
711                                $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
712                        }
713                        return true;
714                }
715                $this->fields = false;
716                return false;
717        }
718       
719        function _close()
720        {
721                return @odbc_free_result($this->_queryID);             
722        }
723
724}
725
726?>
Note: See TracBrowser for help on using the repository browser.