Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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