ChangeLog
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / adodb / drivers / adodb-mysql.inc.php
1 <?php
2 /*
3 V4.90 8 June 2006 (c) 2000-2006 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.
7 Set tabs to 8.
8
9 MySQL code that does not support transactions. Use mysqlt if you need transactions.
10 Requires mysql client. Works on Windows and Unix.
11
12 28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
13 */
14
15 // security - hide paths
16 if (!defined('ADODB_DIR')) die();
17
18 if (! defined("_ADODB_MYSQL_LAYER")) {
19 define("_ADODB_MYSQL_LAYER", 1 );
20
21 class ADODB_mysql extends ADOConnection {
22 var $databaseType = 'mysql';
23 var $dataProvider = 'mysql';
24 var $hasInsertID = true;
25 var $hasAffectedRows = true;
26 var $metaTablesSQL = "SHOW TABLES";
27 var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
28 var $fmtTimeStamp = "'Y-m-d H:i:s'";
29 var $hasLimit = true;
30 var $hasMoveFirst = true;
31 var $hasGenID = true;
32 var $isoDates = true; // accepts dates in ISO format
33 var $sysDate = 'CURDATE()';
34 var $sysTimeStamp = 'NOW()';
35 var $hasTransactions = false;
36 var $forceNewConnect = false;
37 var $poorAffectedRows = true;
38 var $clientFlags = 0;
39 var $substr = "substring";
40 var $nameQuote = '`'; /// string to use to quote identifiers and names
41 var $compat323 = false; // true if compat with mysql 3.23
42
43 function ADODB_mysql()
44 {
45 if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
46 }
47
48 function ServerInfo()
49 {
50 $arr['description'] = ADOConnection::GetOne("select version()");
51 $arr['version'] = ADOConnection::_findvers($arr['description']);
52 return $arr;
53 }
54
55 function IfNull( $field, $ifNull )
56 {
57 return " IFNULL($field, $ifNull) "; // if MySQL
58 }
59
60
61 function &MetaTables($ttype=false,$showSchema=false,$mask=false)
62 {
63 $save = $this->metaTablesSQL;
64 if ($showSchema && is_string($showSchema)) {
65 $this->metaTablesSQL .= " from $showSchema";
66 }
67
68 if ($mask) {
69 $mask = $this->qstr($mask);
70 $this->metaTablesSQL .= " like $mask";
71 }
72 $ret =& ADOConnection::MetaTables($ttype,$showSchema);
73
74 $this->metaTablesSQL = $save;
75 return $ret;
76 }
77
78
79 function &MetaIndexes ($table, $primary = FALSE, $owner=false)
80 {
81 // save old fetch mode
82 global $ADODB_FETCH_MODE;
83
84 $false = false;
85 $save = $ADODB_FETCH_MODE;
86 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
87 if ($this->fetchMode !== FALSE) {
88 $savem = $this->SetFetchMode(FALSE);
89 }
90
91 // get index details
92 $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
93
94 // restore fetchmode
95 if (isset($savem)) {
96 $this->SetFetchMode($savem);
97 }
98 $ADODB_FETCH_MODE = $save;
99
100 if (!is_object($rs)) {
101 return $false;
102 }
103
104 $indexes = array ();
105
106 // parse index data into array
107 while ($row = $rs->FetchRow()) {
108 if ($primary == FALSE AND $row[2] == 'PRIMARY') {
109 continue;
110 }
111
112 if (!isset($indexes[$row[2]])) {
113 $indexes[$row[2]] = array(
114 'unique' => ($row[1] == 0),
115 'columns' => array()
116 );
117 }
118
119 $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
120 }
121
122 // sort columns by order in the index
123 foreach ( array_keys ($indexes) as $index )
124 {
125 ksort ($indexes[$index]['columns']);
126 }
127
128 return $indexes;
129 }
130
131
132 // if magic quotes disabled, use mysql_real_escape_string()
133 function qstr($s,$magic_quotes=false)
134 {
135 if (!$magic_quotes) {
136
137 if (ADODB_PHPVER >= 0x4300) {
138 if (is_resource($this->_connectionID))
139 return "'".mysql_real_escape_string($s,$this->_connectionID)."'";
140 }
141 if ($this->replaceQuote[0] == '\\'){
142 $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
143 }
144 return "'".str_replace("'",$this->replaceQuote,$s)."'";
145 }
146
147 // undo magic quotes for "
148 $s = str_replace('\\"','"',$s);
149 return "'$s'";
150 }
151
152 function _insertid()
153 {
154 return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
155 //return mysql_insert_id($this->_connectionID);
156 }
157
158 function GetOne($sql,$inputarr=false)
159 {
160 if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) {
161 $rs =& $this->SelectLimit($sql,1,-1,$inputarr);
162 if ($rs) {
163 $rs->Close();
164 if ($rs->EOF) return false;
165 return reset($rs->fields);
166 }
167 } else {
168 return ADOConnection::GetOne($sql,$inputarr);
169 }
170 return false;
171 }
172
173 function BeginTrans()
174 {
175 if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
176 }
177
178 function _affectedrows()
179 {
180 return mysql_affected_rows($this->_connectionID);
181 }
182
183 // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
184 // Reference on Last_Insert_ID on the recommended way to simulate sequences
185 var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
186 var $_genSeqSQL = "create table %s (id int not null)";
187 var $_genSeq2SQL = "insert into %s values (%s)";
188 var $_dropSeqSQL = "drop table %s";
189
190 function CreateSequence($seqname='adodbseq',$startID=1)
191 {
192 if (empty($this->_genSeqSQL)) return false;
193 $u = strtoupper($seqname);
194
195 $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
196 if (!$ok) return false;
197 return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
198 }
199
200
201 function GenID($seqname='adodbseq',$startID=1)
202 {
203 // post-nuke sets hasGenID to false
204 if (!$this->hasGenID) return false;
205
206 $savelog = $this->_logsql;
207 $this->_logsql = false;
208 $getnext = sprintf($this->_genIDSQL,$seqname);
209 $holdtransOK = $this->_transOK; // save the current status
210 $rs = @$this->Execute($getnext);
211 if (!$rs) {
212 if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
213 $u = strtoupper($seqname);
214 $this->Execute(sprintf($this->_genSeqSQL,$seqname));
215 $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
216 $rs = $this->Execute($getnext);
217 }
218 $this->genID = mysql_insert_id($this->_connectionID);
219
220 if ($rs) $rs->Close();
221
222 $this->_logsql = $savelog;
223 return $this->genID;
224 }
225
226 function &MetaDatabases()
227 {
228 $qid = mysql_list_dbs($this->_connectionID);
229 $arr = array();
230 $i = 0;
231 $max = mysql_num_rows($qid);
232 while ($i < $max) {
233 $db = mysql_tablename($qid,$i);
234 if ($db != 'mysql') $arr[] = $db;
235 $i += 1;
236 }
237 return $arr;
238 }
239
240
241 // Format date column in sql string given an input format that understands Y M D
242 function SQLDate($fmt, $col=false)
243 {
244 if (!$col) $col = $this->sysTimeStamp;
245 $s = 'DATE_FORMAT('.$col.",'";
246 $concat = false;
247 $len = strlen($fmt);
248 for ($i=0; $i < $len; $i++) {
249 $ch = $fmt[$i];
250 switch($ch) {
251
252 default:
253 if ($ch == '\\') {
254 $i++;
255 $ch = substr($fmt,$i,1);
256 }
257 /** FALL THROUGH */
258 case '-':
259 case '/':
260 $s .= $ch;
261 break;
262
263 case 'Y':
264 case 'y':
265 $s .= '%Y';
266 break;
267 case 'M':
268 $s .= '%b';
269 break;
270
271 case 'm':
272 $s .= '%m';
273 break;
274 case 'D':
275 case 'd':
276 $s .= '%d';
277 break;
278
279 case 'Q':
280 case 'q':
281 $s .= "'),Quarter($col)";
282
283 if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
284 else $s .= ",('";
285 $concat = true;
286 break;
287
288 case 'H':
289 $s .= '%H';
290 break;
291
292 case 'h':
293 $s .= '%I';
294 break;
295
296 case 'i':
297 $s .= '%i';
298 break;
299
300 case 's':
301 $s .= '%s';
302 break;
303
304 case 'a':
305 case 'A':
306 $s .= '%p';
307 break;
308
309 case 'w':
310 $s .= '%w';
311 break;
312
313 case 'W':
314 $s .= '%U';
315 break;
316
317 case 'l':
318 $s .= '%W';
319 break;
320 }
321 }
322 $s.="')";
323 if ($concat) $s = "CONCAT($s)";
324 return $s;
325 }
326
327
328 // returns concatenated string
329 // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
330 function Concat()
331 {
332 $s = "";
333 $arr = func_get_args();
334
335 // suggestion by andrew005@mnogo.ru
336 $s = implode(',',$arr);
337 if (strlen($s) > 0) return "CONCAT($s)";
338 else return '';
339 }
340
341 function OffsetDate($dayFraction,$date=false)
342 {
343 if (!$date) $date = $this->sysDate;
344 $fraction = $dayFraction * 24 * 3600;
345 return "from_unixtime(unix_timestamp($date)+$fraction)";
346 }
347
348 // returns true or false
349 function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
350 {
351 if (!empty($this->port)) $argHostname .= ":".$this->port;
352
353 if (ADODB_PHPVER >= 0x4300)
354 $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
355 $this->forceNewConnect,$this->clientFlags);
356 else if (ADODB_PHPVER >= 0x4200)
357 $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
358 $this->forceNewConnect);
359 else
360 $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
361
362 if ($this->_connectionID === false) return false;
363 if ($argDatabasename) return $this->SelectDB($argDatabasename);
364 return true;
365 }
366
367 // returns true or false
368 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
369 {
370 if (!empty($this->port)) $argHostname .= ":".$this->port;
371
372 if (ADODB_PHPVER >= 0x4300)
373 $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
374 else
375 $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
376 if ($this->_connectionID === false) return false;
377 if ($this->autoRollback) $this->RollbackTrans();
378 if ($argDatabasename) return $this->SelectDB($argDatabasename);
379 return true;
380 }
381
382 function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
383 {
384 $this->forceNewConnect = true;
385 return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
386 }
387
388 function &MetaColumns($table)
389 {
390 $this->_findschema($table,$schema);
391 if ($schema) {
392 $dbName = $this->database;
393 $this->SelectDB($schema);
394 }
395 global $ADODB_FETCH_MODE;
396 $save = $ADODB_FETCH_MODE;
397 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
398
399 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
400 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
401
402 if ($schema) {
403 $this->SelectDB($dbName);
404 }
405
406 if (isset($savem)) $this->SetFetchMode($savem);
407 $ADODB_FETCH_MODE = $save;
408 if (!is_object($rs)) {
409 $false = false;
410 return $false;
411 }
412
413 $retarr = array();
414 while (!$rs->EOF){
415 $fld = new ADOFieldObject();
416 $fld->name = $rs->fields[0];
417 $type = $rs->fields[1];
418
419 // split type into type(length):
420 $fld->scale = null;
421 if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
422 $fld->type = $query_array[1];
423 $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
424 $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
425 } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
426 $fld->type = $query_array[1];
427 $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
428 } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
429 $fld->type = $query_array[1];
430 $arr = explode(",",$query_array[2]);
431 $fld->enums = $arr;
432 $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
433 $fld->max_length = ($zlen > 0) ? $zlen : 1;
434 } else {
435 $fld->type = $type;
436 $fld->max_length = -1;
437 }
438 $fld->not_null = ($rs->fields[2] != 'YES');
439 $fld->primary_key = ($rs->fields[3] == 'PRI');
440 $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
441 $fld->binary = (strpos($type,'blob') !== false);
442 $fld->unsigned = (strpos($type,'unsigned') !== false);
443
444 if (!$fld->binary) {
445 $d = $rs->fields[4];
446 if ($d != '' && $d != 'NULL') {
447 $fld->has_default = true;
448 $fld->default_value = $d;
449 } else {
450 $fld->has_default = false;
451 }
452 }
453
454 if ($save == ADODB_FETCH_NUM) {
455 $retarr[] = $fld;
456 } else {
457 $retarr[strtoupper($fld->name)] = $fld;
458 }
459 $rs->MoveNext();
460 }
461
462 $rs->Close();
463 return $retarr;
464 }
465
466 // returns true or false
467 function SelectDB($dbName)
468 {
469 $this->database = $dbName;
470 $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
471 if ($this->_connectionID) {
472 return @mysql_select_db($dbName,$this->_connectionID);
473 }
474 else return false;
475 }
476
477 // parameters use PostgreSQL convention, not MySQL
478 function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
479 {
480 $offsetStr =($offset>=0) ? ((integer)$offset)."," : '';
481 // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
482 if ($nrows < 0) $nrows = '18446744073709551615';
483
484 if ($secs)
485 $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
486 else
487 $rs =& $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
488 return $rs;
489 }
490
491 // returns queryID or false
492 function _query($sql,$inputarr)
493 {
494 //global $ADODB_COUNTRECS;
495 //if($ADODB_COUNTRECS)
496 return mysql_query($sql,$this->_connectionID);
497 //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
498 }
499
500 /* Returns: the last error message from previous database operation */
501 function ErrorMsg()
502 {
503
504 if ($this->_logsql) return $this->_errorMsg;
505 if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error();
506 else $this->_errorMsg = @mysql_error($this->_connectionID);
507 return $this->_errorMsg;
508 }
509
510 /* Returns: the last error number from previous database operation */
511 function ErrorNo()
512 {
513 if ($this->_logsql) return $this->_errorCode;
514 if (empty($this->_connectionID)) return @mysql_errno();
515 else return @mysql_errno($this->_connectionID);
516 }
517
518 // returns true or false
519 function _close()
520 {
521 @mysql_close($this->_connectionID);
522 $this->_connectionID = false;
523 }
524
525
526 /*
527 * Maximum size of C field
528 */
529 function CharMax()
530 {
531 return 255;
532 }
533
534 /*
535 * Maximum size of X field
536 */
537 function TextMax()
538 {
539 return 4294967295;
540 }
541
542 // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
543 function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
544 {
545 global $ADODB_FETCH_MODE;
546 if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true;
547
548 if ( !empty($owner) ) {
549 $table = "$owner.$table";
550 }
551 $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
552 if ($associative) $create_sql = $a_create_table["Create Table"];
553 else $create_sql = $a_create_table[1];
554
555 $matches = array();
556
557 if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
558 $foreign_keys = array();
559 $num_keys = count($matches[0]);
560 for ( $i = 0; $i < $num_keys; $i ++ ) {
561 $my_field = explode('`, `', $matches[1][$i]);
562 $ref_table = $matches[2][$i];
563 $ref_field = explode('`, `', $matches[3][$i]);
564
565 if ( $upper ) {
566 $ref_table = strtoupper($ref_table);
567 }
568
569 $foreign_keys[$ref_table] = array();
570 $num_fields = count($my_field);
571 for ( $j = 0; $j < $num_fields; $j ++ ) {
572 if ( $associative ) {
573 $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
574 } else {
575 $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
576 }
577 }
578 }
579
580 return $foreign_keys;
581 }
582
583
584 }
585
586 /*--------------------------------------------------------------------------------------
587 Class Name: Recordset
588 --------------------------------------------------------------------------------------*/
589
590
591 class ADORecordSet_mysql extends ADORecordSet{
592
593 var $databaseType = "mysql";
594 var $canSeek = true;
595
596 function ADORecordSet_mysql($queryID,$mode=false)
597 {
598 if ($mode === false) {
599 global $ADODB_FETCH_MODE;
600 $mode = $ADODB_FETCH_MODE;
601 }
602 switch ($mode)
603 {
604 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
605 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
606 case ADODB_FETCH_DEFAULT:
607 case ADODB_FETCH_BOTH:
608 default:
609 $this->fetchMode = MYSQL_BOTH; break;
610 }
611 $this->adodbFetchMode = $mode;
612 $this->ADORecordSet($queryID);
613 }
614
615 function _initrs()
616 {
617 //GLOBAL $ADODB_COUNTRECS;
618 // $this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1;
619 $this->_numOfRows = @mysql_num_rows($this->_queryID);
620 $this->_numOfFields = @mysql_num_fields($this->_queryID);
621 }
622
623 function &FetchField($fieldOffset = -1)
624 {
625 if ($fieldOffset != -1) {
626 $o = @mysql_fetch_field($this->_queryID, $fieldOffset);
627 $f = @mysql_field_flags($this->_queryID,$fieldOffset);
628 $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com)
629 //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
630 $o->binary = (strpos($f,'binary')!== false);
631 }
632 else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
633 $o = @mysql_fetch_field($this->_queryID);
634 $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com)
635 //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
636 }
637
638 return $o;
639 }
640
641 function &GetRowAssoc($upper=true)
642 {
643 if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields;
644 else $row =& ADORecordSet::GetRowAssoc($upper);
645 return $row;
646 }
647
648 /* Use associative array to get fields array */
649 function Fields($colname)
650 {
651 // added @ by "Michael William Miller" <mille562@pilot.msu.edu>
652 if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname];
653
654 if (!$this->bind) {
655 $this->bind = array();
656 for ($i=0; $i < $this->_numOfFields; $i++) {
657 $o = $this->FetchField($i);
658 $this->bind[strtoupper($o->name)] = $i;
659 }
660 }
661 return $this->fields[$this->bind[strtoupper($colname)]];
662 }
663
664 function _seek($row)
665 {
666 if ($this->_numOfRows == 0) return false;
667 return @mysql_data_seek($this->_queryID,$row);
668 }
669
670 function MoveNext()
671 {
672 //return adodb_movenext($this);
673 //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
674 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
675 $this->_currentRow += 1;
676 return true;
677 }
678 if (!$this->EOF) {
679 $this->_currentRow += 1;
680 $this->EOF = true;
681 }
682 return false;
683 }
684
685 function _fetch()
686 {
687 $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
688 return is_array($this->fields);
689 }
690
691 function _close() {
692 @mysql_free_result($this->_queryID);
693 $this->_queryID = false;
694 }
695
696 function MetaType($t,$len=-1,$fieldobj=false)
697 {
698 if (is_object($t)) {
699 $fieldobj = $t;
700 $t = $fieldobj->type;
701 $len = $fieldobj->max_length;
702 }
703
704 $len = -1; // mysql max_length is not accurate
705 switch (strtoupper($t)) {
706 case 'STRING':
707 case 'CHAR':
708 case 'VARCHAR':
709 case 'TINYBLOB':
710 case 'TINYTEXT':
711 case 'ENUM':
712 case 'SET':
713 if ($len <= $this->blobSize) return 'C';
714
715 case 'TEXT':
716 case 'LONGTEXT':
717 case 'MEDIUMTEXT':
718 return 'X';
719
720 // php_mysql extension always returns 'blob' even if 'text'
721 // so we have to check whether binary...
722 case 'IMAGE':
723 case 'LONGBLOB':
724 case 'BLOB':
725 case 'MEDIUMBLOB':
726 return !empty($fieldobj->binary) ? 'B' : 'X';
727
728 case 'YEAR':
729 case 'DATE': return 'D';
730
731 case 'TIME':
732 case 'DATETIME':
733 case 'TIMESTAMP': return 'T';
734
735 case 'INT':
736 case 'INTEGER':
737 case 'BIGINT':
738 case 'TINYINT':
739 case 'MEDIUMINT':
740 case 'SMALLINT':
741
742 if (!empty($fieldobj->primary_key)) return 'R';
743 else return 'I';
744
745 default: return 'N';
746 }
747 }
748
749 }
750
751 class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
752 function ADORecordSet_ext_mysql($queryID,$mode=false)
753 {
754 if ($mode === false) {
755 global $ADODB_FETCH_MODE;
756 $mode = $ADODB_FETCH_MODE;
757 }
758 switch ($mode)
759 {
760 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
761 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
762 case ADODB_FETCH_DEFAULT:
763 case ADODB_FETCH_BOTH:
764 default:
765 $this->fetchMode = MYSQL_BOTH; break;
766 }
767 $this->adodbFetchMode = $mode;
768 $this->ADORecordSet($queryID);
769 }
770
771 function MoveNext()
772 {
773 return @adodb_movenext($this);
774 }
775 }
776
777
778 }
779 ?>