00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 if (!defined('ADODB_DIR')) die();
00018
00019 if (! defined("_ADODB_MYSQLI_LAYER")) {
00020 define("_ADODB_MYSQLI_LAYER", 1 );
00021
00022
00023 if (! defined("MYSQLI_BINARY_FLAG")) define("MYSQLI_BINARY_FLAG", 128);
00024 if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1);
00025
00026
00027 global $ADODB_EXTENSION; $ADODB_EXTENSION = false;
00028
00029 class ADODB_mysqli extends ADOConnection {
00030 var $databaseType = 'mysqli';
00031 var $dataProvider = 'native';
00032 var $hasInsertID = true;
00033 var $hasAffectedRows = true;
00034 var $metaTablesSQL = "SHOW TABLES";
00035 var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
00036 var $fmtTimeStamp = "'Y-m-d H:i:s'";
00037 var $hasLimit = true;
00038 var $hasMoveFirst = true;
00039 var $hasGenID = true;
00040 var $isoDates = true;
00041 var $sysDate = 'CURDATE()';
00042 var $sysTimeStamp = 'NOW()';
00043 var $hasTransactions = true;
00044 var $forceNewConnect = false;
00045 var $poorAffectedRows = true;
00046 var $clientFlags = 0;
00047 var $substr = "substring";
00048 var $port = false;
00049 var $socket = false;
00050 var $_bindInputArray = false;
00051 var $nameQuote = '`';
00052 var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0));
00053
00054 function ADODB_mysqli()
00055 {
00056
00057 ;
00058
00059 }
00060
00061 function SetTransactionMode( $transaction_mode )
00062 {
00063 $this->_transmode = $transaction_mode;
00064 if (empty($transaction_mode)) {
00065 $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
00066 return;
00067 }
00068 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
00069 $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
00070 }
00071
00072
00073
00074
00075 function _connect($argHostname = NULL,
00076 $argUsername = NULL,
00077 $argPassword = NULL,
00078 $argDatabasename = NULL, $persist=false)
00079 {
00080 if(!extension_loaded("mysqli")) {
00081 return null;
00082 }
00083 $this->_connectionID = @mysqli_init();
00084
00085 if (is_null($this->_connectionID)) {
00086
00087 if ($this->debug)
00088 ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
00089 return false;
00090 }
00091
00092
00093
00094
00095
00096 foreach($this->optionFlags as $arr) {
00097 mysqli_options($this->_connectionID,$arr[0],$arr[1]);
00098 }
00099
00100 #if (!empty($this->port)) $argHostname .= ":".$this->port;
00101 $ok = mysqli_real_connect($this->_connectionID,
00102 $argHostname,
00103 $argUsername,
00104 $argPassword,
00105 $argDatabasename,
00106 $this->port,
00107 $this->socket,
00108 $this->clientFlags);
00109
00110 if ($ok) {
00111 if ($argDatabasename) return $this->SelectDB($argDatabasename);
00112 return true;
00113 } else {
00114 if ($this->debug)
00115 ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
00116 return false;
00117 }
00118 }
00119
00120
00121
00122 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
00123 {
00124 return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
00125
00126 }
00127
00128
00129
00130 function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
00131 {
00132 $this->forceNewConnect = true;
00133 return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
00134 }
00135
00136 function IfNull( $field, $ifNull )
00137 {
00138 return " IFNULL($field, $ifNull) ";
00139 }
00140
00141
00142 function GetOne($sql,$inputarr=false)
00143 {
00144 $ret = false;
00145 $rs = &$this->Execute($sql,$inputarr);
00146 if ($rs) {
00147 if (!$rs->EOF) $ret = reset($rs->fields);
00148 $rs->Close();
00149 }
00150 return $ret;
00151 }
00152
00153 function ServerInfo()
00154 {
00155 $arr['description'] = $this->GetOne("select version()");
00156 $arr['version'] = ADOConnection::_findvers($arr['description']);
00157 return $arr;
00158 }
00159
00160
00161 function BeginTrans()
00162 {
00163 if ($this->transOff) return true;
00164 $this->transCnt += 1;
00165
00166
00167 mysqli_autocommit($this->_connectionID, false);
00168 $this->Execute('BEGIN');
00169 return true;
00170 }
00171
00172 function CommitTrans($ok=true)
00173 {
00174 if ($this->transOff) return true;
00175 if (!$ok) return $this->RollbackTrans();
00176
00177 if ($this->transCnt) $this->transCnt -= 1;
00178 $this->Execute('COMMIT');
00179
00180
00181 mysqli_autocommit($this->_connectionID, true);
00182 return true;
00183 }
00184
00185 function RollbackTrans()
00186 {
00187 if ($this->transOff) return true;
00188 if ($this->transCnt) $this->transCnt -= 1;
00189 $this->Execute('ROLLBACK');
00190
00191 mysqli_autocommit($this->_connectionID, true);
00192 return true;
00193 }
00194
00195 function RowLock($tables,$where='',$flds='1 as adodb_ignore')
00196 {
00197 if ($this->transCnt==0) $this->BeginTrans();
00198 if ($where) $where = ' where '.$where;
00199 $rs =& $this->Execute("select $flds from $tables $where for update");
00200 return !empty($rs);
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 function qstr($s, $magic_quotes = false)
00214 {
00215 if (!$magic_quotes) {
00216 if (PHP_VERSION >= 5)
00217 return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
00218
00219 if ($this->replaceQuote[0] == '\\')
00220 $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
00221 return "'".str_replace("'",$this->replaceQuote,$s)."'";
00222 }
00223
00224 $s = str_replace('\\"','"',$s);
00225 return "'$s'";
00226 }
00227
00228 function _insertid()
00229 {
00230 $result = @mysqli_insert_id($this->_connectionID);
00231 if ($result == -1){
00232 if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
00233 }
00234 return $result;
00235 }
00236
00237
00238 function _affectedrows()
00239 {
00240 $result = @mysqli_affected_rows($this->_connectionID);
00241 if ($result == -1) {
00242 if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->ErrorMsg());
00243 }
00244 return $result;
00245 }
00246
00247
00248
00249 var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
00250 var $_genSeqSQL = "create table %s (id int not null)";
00251 var $_genSeq2SQL = "insert into %s values (%s)";
00252 var $_dropSeqSQL = "drop table %s";
00253
00254 function CreateSequence($seqname='adodbseq',$startID=1)
00255 {
00256 if (empty($this->_genSeqSQL)) return false;
00257 $u = strtoupper($seqname);
00258
00259 $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
00260 if (!$ok) return false;
00261 return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
00262 }
00263
00264 function GenID($seqname='adodbseq',$startID=1)
00265 {
00266
00267 if (!$this->hasGenID) return false;
00268
00269 $getnext = sprintf($this->_genIDSQL,$seqname);
00270 $holdtransOK = $this->_transOK;
00271 $rs = @$this->Execute($getnext);
00272 if (!$rs) {
00273 if ($holdtransOK) $this->_transOK = true;
00274 $u = strtoupper($seqname);
00275 $this->Execute(sprintf($this->_genSeqSQL,$seqname));
00276 $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
00277 $rs = $this->Execute($getnext);
00278 }
00279 $this->genID = mysqli_insert_id($this->_connectionID);
00280
00281 if ($rs) $rs->Close();
00282
00283 return $this->genID;
00284 }
00285
00286 function &MetaDatabases()
00287 {
00288 $query = "SHOW DATABASES";
00289 $ret =& $this->Execute($query);
00290 if ($ret && is_object($ret)){
00291 $arr = array();
00292 while (!$ret->EOF){
00293 $db = $ret->Fields('Database');
00294 if ($db != 'mysql') $arr[] = $db;
00295 $ret->MoveNext();
00296 }
00297 return $arr;
00298 }
00299 return $ret;
00300 }
00301
00302
00303 function &MetaIndexes ($table, $primary = FALSE)
00304 {
00305
00306 global $ADODB_FETCH_MODE;
00307
00308 $false = false;
00309 $save = $ADODB_FETCH_MODE;
00310 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00311 if ($this->fetchMode !== FALSE) {
00312 $savem = $this->SetFetchMode(FALSE);
00313 }
00314
00315
00316 $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
00317
00318
00319 if (isset($savem)) {
00320 $this->SetFetchMode($savem);
00321 }
00322 $ADODB_FETCH_MODE = $save;
00323
00324 if (!is_object($rs)) {
00325 return $false;
00326 }
00327
00328 $indexes = array ();
00329
00330
00331 while ($row = $rs->FetchRow()) {
00332 if ($primary == FALSE AND $row[2] == 'PRIMARY') {
00333 continue;
00334 }
00335
00336 if (!isset($indexes[$row[2]])) {
00337 $indexes[$row[2]] = array(
00338 'unique' => ($row[1] == 0),
00339 'columns' => array()
00340 );
00341 }
00342
00343 $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
00344 }
00345
00346
00347 foreach ( array_keys ($indexes) as $index )
00348 {
00349 ksort ($indexes[$index]['columns']);
00350 }
00351
00352 return $indexes;
00353 }
00354
00355
00356
00357 function SQLDate($fmt, $col=false)
00358 {
00359 if (!$col) $col = $this->sysTimeStamp;
00360 $s = 'DATE_FORMAT('.$col.",'";
00361 $concat = false;
00362 $len = strlen($fmt);
00363 for ($i=0; $i < $len; $i++) {
00364 $ch = $fmt[$i];
00365 switch($ch) {
00366 case 'Y':
00367 case 'y':
00368 $s .= '%Y';
00369 break;
00370 case 'Q':
00371 case 'q':
00372 $s .= "'),Quarter($col)";
00373
00374 if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
00375 else $s .= ",('";
00376 $concat = true;
00377 break;
00378 case 'M':
00379 $s .= '%b';
00380 break;
00381
00382 case 'm':
00383 $s .= '%m';
00384 break;
00385 case 'D':
00386 case 'd':
00387 $s .= '%d';
00388 break;
00389
00390 case 'H':
00391 $s .= '%H';
00392 break;
00393
00394 case 'h':
00395 $s .= '%I';
00396 break;
00397
00398 case 'i':
00399 $s .= '%i';
00400 break;
00401
00402 case 's':
00403 $s .= '%s';
00404 break;
00405
00406 case 'a':
00407 case 'A':
00408 $s .= '%p';
00409 break;
00410
00411 case 'w':
00412 $s .= '%w';
00413 break;
00414
00415 case 'l':
00416 $s .= '%W';
00417 break;
00418
00419 default:
00420
00421 if ($ch == '\\') {
00422 $i++;
00423 $ch = substr($fmt,$i,1);
00424 }
00425 $s .= $ch;
00426 break;
00427 }
00428 }
00429 $s.="')";
00430 if ($concat) $s = "CONCAT($s)";
00431 return $s;
00432 }
00433
00434
00435
00436 function Concat()
00437 {
00438 $s = "";
00439 $arr = func_get_args();
00440
00441
00442 $s = implode(',',$arr);
00443 if (strlen($s) > 0) return "CONCAT($s)";
00444 else return '';
00445 }
00446
00447
00448 function OffsetDate($dayFraction,$date=false)
00449 {
00450 if (!$date) $date = $this->sysDate;
00451
00452 $fraction = $dayFraction * 24 * 3600;
00453 return $date . ' + INTERVAL ' . $fraction.' SECOND';
00454
00455
00456 }
00457
00458 function &MetaTables($ttype=false,$showSchema=false,$mask=false)
00459 {
00460 $save = $this->metaTablesSQL;
00461 if ($showSchema && is_string($showSchema)) {
00462 $this->metaTablesSQL .= " from $showSchema";
00463 }
00464
00465 if ($mask) {
00466 $mask = $this->qstr($mask);
00467 $this->metaTablesSQL .= " like $mask";
00468 }
00469 $ret =& ADOConnection::MetaTables($ttype,$showSchema);
00470
00471 $this->metaTablesSQL = $save;
00472 return $ret;
00473 }
00474
00475
00476 function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
00477 {
00478 global $ADODB_FETCH_MODE;
00479
00480 if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true;
00481
00482 if ( !empty($owner) ) {
00483 $table = "$owner.$table";
00484 }
00485 $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
00486 if ($associative) $create_sql = $a_create_table["Create Table"];
00487 else $create_sql = $a_create_table[1];
00488
00489 $matches = array();
00490
00491 if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
00492 $foreign_keys = array();
00493 $num_keys = count($matches[0]);
00494 for ( $i = 0; $i < $num_keys; $i ++ ) {
00495 $my_field = explode('`, `', $matches[1][$i]);
00496 $ref_table = $matches[2][$i];
00497 $ref_field = explode('`, `', $matches[3][$i]);
00498
00499 if ( $upper ) {
00500 $ref_table = strtoupper($ref_table);
00501 }
00502
00503 $foreign_keys[$ref_table] = array();
00504 $num_fields = count($my_field);
00505 for ( $j = 0; $j < $num_fields; $j ++ ) {
00506 if ( $associative ) {
00507 $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
00508 } else {
00509 $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
00510 }
00511 }
00512 }
00513
00514 return $foreign_keys;
00515 }
00516
00517 function &MetaColumns($table)
00518 {
00519 $false = false;
00520 if (!$this->metaColumnsSQL)
00521 return $false;
00522
00523 global $ADODB_FETCH_MODE;
00524 $save = $ADODB_FETCH_MODE;
00525 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00526 if ($this->fetchMode !== false)
00527 $savem = $this->SetFetchMode(false);
00528 $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
00529 if (isset($savem)) $this->SetFetchMode($savem);
00530 $ADODB_FETCH_MODE = $save;
00531 if (!is_object($rs))
00532 return $false;
00533
00534 $retarr = array();
00535 while (!$rs->EOF) {
00536 $fld = new ADOFieldObject();
00537 $fld->name = $rs->fields[0];
00538 $type = $rs->fields[1];
00539
00540
00541 $fld->scale = null;
00542 if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
00543 $fld->type = $query_array[1];
00544 $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
00545 $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
00546 } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
00547 $fld->type = $query_array[1];
00548 $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
00549 } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
00550 $fld->type = $query_array[1];
00551 $fld->max_length = max(array_map("strlen",explode(",",$query_array[2]))) - 2;
00552 $fld->max_length = ($fld->max_length == 0 ? 1 : $fld->max_length);
00553 } else {
00554 $fld->type = $type;
00555 $fld->max_length = -1;
00556 }
00557 $fld->not_null = ($rs->fields[2] != 'YES');
00558 $fld->primary_key = ($rs->fields[3] == 'PRI');
00559 $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
00560 $fld->binary = (strpos($type,'blob') !== false);
00561 $fld->unsigned = (strpos($type,'unsigned') !== false);
00562
00563 if (!$fld->binary) {
00564 $d = $rs->fields[4];
00565 if ($d != '' && $d != 'NULL') {
00566 $fld->has_default = true;
00567 $fld->default_value = $d;
00568 } else {
00569 $fld->has_default = false;
00570 }
00571 }
00572
00573 if ($save == ADODB_FETCH_NUM) {
00574 $retarr[] = $fld;
00575 } else {
00576 $retarr[strtoupper($fld->name)] = $fld;
00577 }
00578 $rs->MoveNext();
00579 }
00580
00581 $rs->Close();
00582 return $retarr;
00583 }
00584
00585
00586 function SelectDB($dbName)
00587 {
00588
00589 $this->database = $dbName;
00590 $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
00591
00592 if ($this->_connectionID) {
00593 $result = @mysqli_select_db($this->_connectionID, $dbName);
00594 if (!$result) {
00595 ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg());
00596 }
00597 return $result;
00598 }
00599 return false;
00600 }
00601
00602
00603 function &SelectLimit($sql,
00604 $nrows = -1,
00605 $offset = -1,
00606 $inputarr = false,
00607 $arg3 = false,
00608 $secs = 0)
00609 {
00610 $offsetStr = ($offset >= 0) ? "$offset," : '';
00611 if ($nrows < 0) $nrows = '18446744073709551615';
00612
00613 if ($secs)
00614 $rs =& $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
00615 else
00616 $rs =& $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
00617
00618 return $rs;
00619 }
00620
00621
00622 function Prepare($sql)
00623 {
00624 return $sql;
00625
00626 $stmt = $this->_connectionID->prepare($sql);
00627 if (!$stmt) {
00628 echo $this->ErrorMsg();
00629 return $sql;
00630 }
00631 return array($sql,$stmt);
00632 }
00633
00634
00635
00636 function _query($sql, $inputarr)
00637 {
00638 global $ADODB_COUNTRECS;
00639
00640 if (is_array($sql)) {
00641 $stmt = $sql[1];
00642 $a = '';
00643 foreach($inputarr as $k => $v) {
00644 if (is_string($v)) $a .= 's';
00645 else if (is_integer($v)) $a .= 'i';
00646 else $a .= 'd';
00647 }
00648
00649 $fnarr = array_merge( array($stmt,$a) , $inputarr);
00650 $ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
00651
00652 $ret = mysqli_stmt_execute($stmt);
00653 return $ret;
00654 }
00655 if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
00656 if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
00657 return false;
00658 }
00659
00660 return $mysql_res;
00661 }
00662
00663
00664 function ErrorMsg()
00665 {
00666 if (empty($this->_connectionID))
00667 $this->_errorMsg = @mysqli_connect_error();
00668 else
00669 $this->_errorMsg = @mysqli_error($this->_connectionID);
00670 return $this->_errorMsg;
00671 }
00672
00673
00674 function ErrorNo()
00675 {
00676 if (empty($this->_connectionID))
00677 return @mysqli_connect_errno();
00678 else
00679 return @mysqli_errno($this->_connectionID);
00680 }
00681
00682
00683 function _close()
00684 {
00685 @mysqli_close($this->_connectionID);
00686 $this->_connectionID = false;
00687 }
00688
00689
00690
00691
00692 function CharMax()
00693 {
00694 return 255;
00695 }
00696
00697
00698
00699
00700 function TextMax()
00701 {
00702 return 4294967295;
00703 }
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 function GetCharSet()
00715 {
00716
00717 if (!method_exists($this->_connectionID,'character_set_name'))
00718 return false;
00719
00720 $this->charSet = @$this->_connectionID->character_set_name();
00721 if (!$this->charSet) {
00722 return false;
00723 } else {
00724 return $this->charSet;
00725 }
00726 }
00727
00728
00729 function SetCharSet($charset_name)
00730 {
00731 if (!method_exists($this->_connectionID,'set_charset'))
00732 return false;
00733
00734 if ($this->charSet !== $charset_name) {
00735 $if = @$this->_connectionID->set_charset($charset_name);
00736 if ($if == "0" & $this->GetCharSet() == $charset_name) {
00737 return true;
00738 } else return false;
00739 } else return true;
00740 }
00741
00742
00743
00744
00745 }
00746
00747
00748
00749
00750
00751 class ADORecordSet_mysqli extends ADORecordSet{
00752
00753 var $databaseType = "mysqli";
00754 var $canSeek = true;
00755
00756 function ADORecordSet_mysqli($queryID, $mode = false)
00757 {
00758 if ($mode === false)
00759 {
00760 global $ADODB_FETCH_MODE;
00761 $mode = $ADODB_FETCH_MODE;
00762 }
00763
00764 switch ($mode)
00765 {
00766 case ADODB_FETCH_NUM:
00767 $this->fetchMode = MYSQLI_NUM;
00768 break;
00769 case ADODB_FETCH_ASSOC:
00770 $this->fetchMode = MYSQLI_ASSOC;
00771 break;
00772 case ADODB_FETCH_DEFAULT:
00773 case ADODB_FETCH_BOTH:
00774 default:
00775 $this->fetchMode = MYSQLI_BOTH;
00776 break;
00777 }
00778 $this->adodbFetchMode = $mode;
00779 $this->ADORecordSet($queryID);
00780 }
00781
00782 function _initrs()
00783 {
00784 global $ADODB_COUNTRECS;
00785
00786 $this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1;
00787 $this->_numOfFields = @mysqli_num_fields($this->_queryID);
00788 }
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810 function &FetchField($fieldOffset = -1)
00811 {
00812 $fieldnr = $fieldOffset;
00813 if ($fieldOffset != -1) {
00814 $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr);
00815 }
00816 $o = mysqli_fetch_field($this->_queryID);
00817
00818 $o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
00819 $o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
00820 $o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG;
00821 $o->binary = $o->flags & MYSQLI_BINARY_FLAG;
00822
00823 $o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG;
00824
00825 return $o;
00826 }
00827
00828 function &GetRowAssoc($upper = true)
00829 {
00830 if ($this->fetchMode == MYSQLI_ASSOC && !$upper)
00831 return $this->fields;
00832 $row =& ADORecordSet::GetRowAssoc($upper);
00833 return $row;
00834 }
00835
00836
00837 function Fields($colname)
00838 {
00839 if ($this->fetchMode != MYSQLI_NUM)
00840 return @$this->fields[$colname];
00841
00842 if (!$this->bind) {
00843 $this->bind = array();
00844 for ($i = 0; $i < $this->_numOfFields; $i++) {
00845 $o = $this->FetchField($i);
00846 $this->bind[strtoupper($o->name)] = $i;
00847 }
00848 }
00849 return $this->fields[$this->bind[strtoupper($colname)]];
00850 }
00851
00852 function _seek($row)
00853 {
00854 if ($this->_numOfRows == 0)
00855 return false;
00856
00857 if ($row < 0)
00858 return false;
00859
00860 mysqli_data_seek($this->_queryID, $row);
00861 $this->EOF = false;
00862 return true;
00863 }
00864
00865
00866
00867
00868 function MoveNext()
00869 {
00870 if ($this->EOF) return false;
00871 $this->_currentRow++;
00872 $this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
00873
00874 if (is_array($this->fields)) return true;
00875 $this->EOF = true;
00876 return false;
00877 }
00878
00879 function _fetch()
00880 {
00881 $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
00882 return is_array($this->fields);
00883 }
00884
00885 function _close()
00886 {
00887 mysqli_free_result($this->_queryID);
00888 $this->_queryID = false;
00889 }
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920 function MetaType($t, $len = -1, $fieldobj = false)
00921 {
00922 if (is_object($t)) {
00923 $fieldobj = $t;
00924 $t = $fieldobj->type;
00925 $len = $fieldobj->max_length;
00926 }
00927
00928
00929 $len = -1;
00930 switch (strtoupper($t)) {
00931 case 'STRING':
00932 case 'CHAR':
00933 case 'VARCHAR':
00934 case 'TINYBLOB':
00935 case 'TINYTEXT':
00936 case 'ENUM':
00937 case 'SET':
00938
00939 case MYSQLI_TYPE_TINY_BLOB :
00940 case MYSQLI_TYPE_CHAR :
00941 case MYSQLI_TYPE_STRING :
00942 case MYSQLI_TYPE_ENUM :
00943 case MYSQLI_TYPE_SET :
00944 case 253 :
00945 if ($len <= $this->blobSize) return 'C';
00946
00947 case 'TEXT':
00948 case 'LONGTEXT':
00949 case 'MEDIUMTEXT':
00950 return 'X';
00951
00952
00953
00954
00955 case 'IMAGE':
00956 case 'LONGBLOB':
00957 case 'BLOB':
00958 case 'MEDIUMBLOB':
00959
00960 case MYSQLI_TYPE_BLOB :
00961 case MYSQLI_TYPE_LONG_BLOB :
00962 case MYSQLI_TYPE_MEDIUM_BLOB :
00963
00964 return !empty($fieldobj->binary) ? 'B' : 'X';
00965 case 'YEAR':
00966 case 'DATE':
00967 case MYSQLI_TYPE_DATE :
00968 case MYSQLI_TYPE_YEAR :
00969
00970 return 'D';
00971
00972 case 'TIME':
00973 case 'DATETIME':
00974 case 'TIMESTAMP':
00975
00976 case MYSQLI_TYPE_DATETIME :
00977 case MYSQLI_TYPE_NEWDATE :
00978 case MYSQLI_TYPE_TIME :
00979 case MYSQLI_TYPE_TIMESTAMP :
00980
00981 return 'T';
00982
00983 case 'INT':
00984 case 'INTEGER':
00985 case 'BIGINT':
00986 case 'TINYINT':
00987 case 'MEDIUMINT':
00988 case 'SMALLINT':
00989
00990 case MYSQLI_TYPE_INT24 :
00991 case MYSQLI_TYPE_LONG :
00992 case MYSQLI_TYPE_LONGLONG :
00993 case MYSQLI_TYPE_SHORT :
00994 case MYSQLI_TYPE_TINY :
00995
00996 if (!empty($fieldobj->primary_key)) return 'R';
00997
00998 return 'I';
00999
01000
01001
01002
01003 case 'FLOAT':
01004 case 'DOUBLE':
01005
01006 case 'DECIMAL':
01007 case 'DEC':
01008 case 'FIXED':
01009 default:
01010
01011 return 'N';
01012 }
01013 }
01014
01015
01016 }
01017
01018 }
01019
01020 ?>