From 101a7afc1fda8c6eff5f22d7bb832757d3f83dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Kacerka?= Date: Thu, 12 Nov 2020 15:35:39 +0100 Subject: [PATCH 1/2] Added support for PDO api in addition to mysqli --- phpminiadmin.php | 155 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 133 insertions(+), 22 deletions(-) diff --git a/phpminiadmin.php b/phpminiadmin.php index b1d1b70..afaf37e 100644 --- a/phpminiadmin.php +++ b/phpminiadmin.php @@ -99,6 +99,15 @@ exit; } +$api_type=0; +if (function_exists('mysqli_connect')) $api_type=1; +if (class_exists('PDO')) { + $api_type=2; + define('MYSQLI_STORE_RESULT',0); + define('MYSQLI_USE_RESULT',1); + $pdo_connect_error = ''; +} + //get initial values $SQLq=trim(b64d($_REQUEST['q'])); $page=intval($_REQUEST['p']); @@ -168,6 +177,106 @@ function do_sql($q){ } } +//* mysqli or PDO +function _mysqli_connect($host,$user,$pass,$db,$po,$so) { + global $api_type, $pdo_connect_error; + switch ($api_type) { + case 1: return mysqli_connect($host,$user,$pass,$db,$po,$so); + case 2: $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; + if ($po) $dsn.=";port=$po"; + if ($so) $dsn.=";unix_socket=$so"; + $options = [PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]; + try { + $pdo_connect_error = ''; + return new PDO($dsn, $user, $pass, $options); + } catch (PDOException $e) { + $pdo_connect_error = $e->getMessage(); + } + } + return null; +} + +function _mysqli_ping($dbh) { + global $api_type; + switch ($api_type) { + case 1: return _mysqli_ping($dbh); + case 2: try { + $dbh->query('SELECT 1'); + } catch (PDOException $e) { + return false; + } + return true; + } +} + +function _mysqli_query($dbh, $sql, $resmod) { + global $api_type; + switch ($api_type) { + case 1: return $dbh->query($sql, $resmod); + case 2: return $dbh->query($sql); + } +} + +function _mysqli_fetch_row($sth) { + global $api_type; + switch ($api_type) { + case 1: return mysqli_fetch_row($sth); + case 2: return $sth->fetch(PDO::FETCH_NUM); + } +} + +function _mysqli_fetch_assoc($sth) { + global $api_type; + switch ($api_type) { + case 1: return mysqli_fetch_assoc($sth); + case 2: return $sth->fetch(PDO::FETCH_ASSOC); + } +} + +function _mysqli_free_result($sth) { + global $api_type; + switch ($api_type) { + case 1: return $sth->free_result(); + case 2: return $sth->closeCursor(); + } +} + +function _mysqli_num_rows($sth) { + global $api_type; + switch ($api_type) { + case 1: return $sth->num_rows(); + case 2: return $sth->rowCount(); + } +} + +function _mysqli_field_count($dbh, $sth) { + global $api_type; + switch ($api_type) { + case 1: return $dbh->field_count(); + case 2: return $sth->columnCount(); + } +} + +function _mysqli_fetch_field($sth,$col) { + global $api_type; + switch ($api_type) { + case 1: return $sth->fetch_field(); + case 2: + $metadata = $sth->getColumnMeta($col); + $ret = new stdClass(); + $ret->name = $metadata["name"]; + return $ret; + } +} + +function _mysqli_connect_error() { + global $api_type, $pdo_connect_error; + switch ($api_type) { + case 1: return mysqli_connect_error(); + case 2: return $pdo_connect_error; + } +} + function display_select($sth,$q){ global $dbh,$DB,$sqldr,$reccount,$is_sht,$xurl,$is_sm; $rc=array("o","e"); @@ -180,8 +289,8 @@ function display_select($sth,$q){ if ($sth===FALSE or $sth===TRUE) return;#check if $sth is not a mysql resource - $reccount=mysqli_num_rows($sth); - $fields_num=mysqli_field_count($dbh); + $reccount=_mysqli_num_rows($sth); + $fields_num=_mysqli_field_count($dbh, $sth); $w=''; if ($is_sm) $w='sm '; @@ -211,7 +320,7 @@ function display_select($sth,$q){ if ($is_sht) $headers.=""; for($i=0;$i<$fields_num;$i++){ if ($is_sht && $i>0) break; - $meta=mysqli_fetch_field($sth); + $meta=_mysqli_fetch_field($sth, $i); $headers.="
".hs($meta->name)."
"; } if ($is_shd) $headers.="show create databaseshow table statusshow triggers"; @@ -219,7 +328,7 @@ function display_select($sth,$q){ $headers.="\n"; $sqldr.=$headers; $swapper=false; - while($row=mysqli_fetch_row($sth)){ + while($row=_mysqli_fetch_row($sth)){ $sqldr.=""; $v=$row[0]; if ($is_sht){ @@ -572,10 +681,10 @@ function db_connect($nodie=0){ mysqli_ssl_set($dbh,$DB['ssl_key'],$DB['ssl_cert'],$DB['ssl_ca'],NULL,NULL); if (!mysqli_real_connect($dbh,$DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so,MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT)) $dbh=null; }else{#non-ssl - $dbh=mysqli_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); + $dbh=_mysqli_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); } if (!$dbh) { - $err_msg='Cannot connect to the database because: '.mysqli_connect_error(); + $err_msg='Cannot connect to the database because: '._mysqli_connect_error(); if (!$nodie) die($err_msg); }else{ if ($DB['chset']) db_query("SET NAMES ".$DB['chset']); @@ -587,7 +696,7 @@ function db_connect($nodie=0){ function db_checkconnect($dbh1=NULL, $skiperr=0){ global $dbh; if (!$dbh1) $dbh1=&$dbh; - if (!$dbh1 or !mysqli_ping($dbh1)) { + if (!$dbh1 or !_mysqli_ping($dbh1)) { db_connect($skiperr); $dbh1=&$dbh; } @@ -607,34 +716,36 @@ function dbq($s){ function db_query($sql, $dbh1=NULL, $skiperr=0, $resmod=MYSQLI_STORE_RESULT){ $dbh1=db_checkconnect($dbh1, $skiperr); - $sth=mysqli_query($dbh1, $sql, $resmod); + $sth=_mysqli_query($dbh1, $sql, $resmod); if (!$sth && $skiperr) return; if (!$sth) die("Error in DB operation:
\n".mysqli_error($dbh1)."
\n$sql"); return $sth; } function db_array($sql, $dbh1=NULL, $skiperr=0, $isnum=0){#array of rows + global $api_type; + if ($api_type != 1 && is_null($dbh1)) return null; $sth=db_query($sql, $dbh1, $skiperr, MYSQLI_USE_RESULT); if (!$sth) return; $res=array(); if ($isnum){ - while($row=mysqli_fetch_row($sth)) $res[]=$row; + while($row=_mysqli_fetch_row($sth)) $res[]=$row; }else{ - while($row=mysqli_fetch_assoc($sth)) $res[]=$row; + while($row=_mysqli_fetch_assoc($sth)) $res[]=$row; } - mysqli_free_result($sth); + _mysqli_free_result($sth); return $res; } function db_row($sql){ $sth=db_query($sql); - return mysqli_fetch_assoc($sth); + return _mysqli_fetch_assoc($sth); } function db_value($sql,$dbh1=NULL,$skiperr=0){ $sth=db_query($sql,$dbh1,$skiperr); if (!$sth) return; - $row=mysqli_fetch_row($sth); + $row=_mysqli_fetch_row($sth); return $row[0]; } @@ -662,7 +773,7 @@ function chset_select($sel=''){ $result=''; if ($_SESSION['sql_chset']){ $arr=$_SESSION['sql_chset']; - }else{ + }else { $arr=db_array("show character set",NULL,1); if (!is_array($arr)) $arr=array(array('Charset'=>$DBDEF['chset'])); $_SESSION['sql_chset']=$arr; @@ -879,14 +990,14 @@ function do_export(){ if ($DB['chset']=='utf8') ex_w($BOM); $sth=db_query("select * from `$t[0]`",NULL,0,MYSQLI_USE_RESULT); - $fn=mysqli_field_count($dbh); + $fn=_mysqli_field_count($dbh, $sth); for($i=0;$i<$fn;$i++){ - $m=mysqli_fetch_field($sth); + $m=_mysqli_fetch_field($sth, $i); ex_w(qstr($m->name).(($i<$fn-1)?",":"")); } ex_w($D); - while($row=mysqli_fetch_row($sth)) ex_w(to_csv_row($row)); - mysqli_free_result($sth); + while($row=_mysqli_fetch_row($sth)) ex_w(to_csv_row($row)); + _mysqli_free_result($sth); }else{ ex_start('.sql'); ex_hdr($ctp?$ctp:'text/plain',"$DB[db]".(($ct==1&&$t[0])?".$t[0]":(($ct>1)?'.'.$ct.'tables':'')).".sql$aext"); @@ -896,7 +1007,7 @@ function do_export(){ ex_w("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;$D$D"); $sth=db_query("show full tables from `$DB[db]`"); - while($row=mysqli_fetch_row($sth)){ + while($row=_mysqli_fetch_row($sth)){ if (!$rt||array_key_exists($row[0],$th)) do_export_table($row[0],$row[1],$MAXI); } @@ -914,7 +1025,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ if($_REQUEST['s']){ $sth=db_query("show create table `$t`"); - $row=mysqli_fetch_row($sth); + $row=_mysqli_fetch_row($sth); $ct=preg_replace("/\n\r|\r\n|\n|\r/",$D,$row[1]); ex_w("DROP TABLE IF EXISTS `$t`;$D$ct;$D$D"); } @@ -923,7 +1034,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ $exsql=''; ex_w("/*!40000 ALTER TABLE `$t` DISABLE KEYS */;$D"); $sth=db_query("select * from `$t`",NULL,0,MYSQLI_USE_RESULT); - while($row=mysqli_fetch_row($sth)){ + while($row=_mysqli_fetch_row($sth)){ $values=''; foreach($row as $v) $values.=(($values)?',':'').dbq($v); $exsql.=(($exsql)?',':'')."(".$values.")"; @@ -931,7 +1042,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ ex_w("INSERT INTO `$t` VALUES $exsql;$D");$exsql=''; } } - mysqli_free_result($sth); + _mysqli_free_result($sth); if ($exsql) ex_w("INSERT INTO `$t` VALUES $exsql;$D"); ex_w("/*!40000 ALTER TABLE `$t` ENABLE KEYS */;$D$D"); } From 9e43ecebad9abe11f0ec1c563167b6136763b80f Mon Sep 17 00:00:00 2001 From: Oleg Savchuk Date: Mon, 5 Jul 2021 20:29:51 -0500 Subject: [PATCH 2/2] code refactoring/fixes. TODO - databases list not displayed --- phpminiadmin.php | 278 ++++++++++++++++++++++++----------------------- 1 file changed, 145 insertions(+), 133 deletions(-) diff --git a/phpminiadmin.php b/phpminiadmin.php index 9a2e3dd..f115bb0 100644 --- a/phpminiadmin.php +++ b/phpminiadmin.php @@ -88,20 +88,24 @@ loadsess(); +$is_pdo=false; +$pdo_err=''; +if (!function_exists('mysqli_connect')){ + if (class_exists('PDO')) { + $is_pdo=true; + define('MYSQLI_STORE_RESULT',0); + define('MYSQLI_USE_RESULT',1); + }else{ + echo "Please install and enable mysqli or PDO extensions"; + exit; + } +}; + if ($_REQUEST['showcfg']){ print_cfg(); exit; } -$api_type=0; -if (function_exists('mysqli_connect')) $api_type=1; -if (class_exists('PDO')) { - $api_type=2; - define('MYSQLI_STORE_RESULT',0); - define('MYSQLI_USE_RESULT',1); - $pdo_connect_error = ''; -} - //get initial values $SQLq=trim(b64d($_REQUEST['q'])); $page=intval($_REQUEST['p']); @@ -171,106 +175,6 @@ function do_sql($q){ } } -//* mysqli or PDO -function _mysqli_connect($host,$user,$pass,$db,$po,$so) { - global $api_type, $pdo_connect_error; - switch ($api_type) { - case 1: return mysqli_connect($host,$user,$pass,$db,$po,$so); - case 2: $dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4"; - if ($po) $dsn.=";port=$po"; - if ($so) $dsn.=";unix_socket=$so"; - $options = [PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]; - try { - $pdo_connect_error = ''; - return new PDO($dsn, $user, $pass, $options); - } catch (PDOException $e) { - $pdo_connect_error = $e->getMessage(); - } - } - return null; -} - -function _mysqli_ping($dbh) { - global $api_type; - switch ($api_type) { - case 1: return _mysqli_ping($dbh); - case 2: try { - $dbh->query('SELECT 1'); - } catch (PDOException $e) { - return false; - } - return true; - } -} - -function _mysqli_query($dbh, $sql, $resmod) { - global $api_type; - switch ($api_type) { - case 1: return $dbh->query($sql, $resmod); - case 2: return $dbh->query($sql); - } -} - -function _mysqli_fetch_row($sth) { - global $api_type; - switch ($api_type) { - case 1: return mysqli_fetch_row($sth); - case 2: return $sth->fetch(PDO::FETCH_NUM); - } -} - -function _mysqli_fetch_assoc($sth) { - global $api_type; - switch ($api_type) { - case 1: return mysqli_fetch_assoc($sth); - case 2: return $sth->fetch(PDO::FETCH_ASSOC); - } -} - -function _mysqli_free_result($sth) { - global $api_type; - switch ($api_type) { - case 1: return $sth->free_result(); - case 2: return $sth->closeCursor(); - } -} - -function _mysqli_num_rows($sth) { - global $api_type; - switch ($api_type) { - case 1: return $sth->num_rows(); - case 2: return $sth->rowCount(); - } -} - -function _mysqli_field_count($dbh, $sth) { - global $api_type; - switch ($api_type) { - case 1: return $dbh->field_count(); - case 2: return $sth->columnCount(); - } -} - -function _mysqli_fetch_field($sth,$col) { - global $api_type; - switch ($api_type) { - case 1: return $sth->fetch_field(); - case 2: - $metadata = $sth->getColumnMeta($col); - $ret = new stdClass(); - $ret->name = $metadata["name"]; - return $ret; - } -} - -function _mysqli_connect_error() { - global $api_type, $pdo_connect_error; - switch ($api_type) { - case 1: return mysqli_connect_error(); - case 2: return $pdo_connect_error; - } -} - function display_select($sth,$q){ global $dbh,$DB,$sqldr,$reccount,$is_sht,$xurl,$is_sm; $rc=array("o","e"); @@ -283,8 +187,8 @@ function display_select($sth,$q){ if ($sth===FALSE or $sth===TRUE) return;#check if $sth is not a mysql resource - $reccount=_mysqli_num_rows($sth); - $fields_num=_mysqli_field_count($dbh, $sth); + $reccount=_db_num_rows($sth); + $fields_num=_db_field_count($dbh, $sth); $w=''; if ($is_sm) $w='sm '; @@ -315,7 +219,7 @@ function display_select($sth,$q){ if ($is_sht) $headers.=""; for($i=0;$i<$fields_num;$i++){ if ($is_sht && $i>0) break; - $meta=_mysqli_fetch_field($sth, $i); + $meta=_db_fetch_field($sth, $i); $headers.="
".hs($meta->name)."
"; } if ($is_shd) $headers.="show create databaseshow table statusshow triggers"; @@ -324,7 +228,7 @@ function display_select($sth,$q){ $sqldr.=$headers; $swapper=false; $swp=0; - while($row=_mysqli_fetch_row($sth)){ + while($row=db_fetch_row($sth)){ $sqldr.=""; $v=$row[0]; if ($is_sht){ @@ -665,7 +569,115 @@ function print_cfg(){ } -//* utilities +# utilities +# _db* for mysqli/PDO support +function _db_connect($host,$user,$pass,$db,$po,$so){ + global $is_pdo,$pdo_err; + if($is_pdo){ + $dsn="mysql:host=$host;dbname=$db;charset=utf8mb4"; + if($po) $dsn.=";port=$po"; + if($so) $dsn.=";unix_socket=$so"; + $options=array(PDO::ATTR_EMULATE_PREPARES=>false,PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC); + try{ + $pdo_err=''; + return new PDO($dsn,$user,$pass,$options); + }catch(PDOException $e){ + $pdo_err=$e->getMessage(); + } + }else{ + return mysqli_connect($host,$user,$pass,$db,$po,$so); + } +} + +function db_ping($dbh){ + global $is_pdo; + if($is_pdo){ + try{ + $dbh->query('SELECT 1'); + }catch(PDOException $e){ + return false; + } + return true; + }else{ + return mysqli_ping($dbh); + } +} + +function _db_query($dbh,$sql,$resmod){ + global $is_pdo; + if($is_pdo){ + return $dbh->query($sql,$resmod); + }else{ + return mysqli_query($dbh,$sql,$resmod); + } +} + +function db_fetch_row($sth){ + global $is_pdo; + if($is_pdo){ + return $sth->fetch(PDO::FETCH_NUM); + }else{ + return mysqli_fetch_row($sth); + } +} + +function db_fetch_assoc($sth){ + global $is_pdo; + if($is_pdo){ + return $sth->fetch(PDO::FETCH_ASSOC); + }else{ + return mysqli_fetch_assoc($sth); + } +} + +function _db_free($sth){ + global $is_pdo; + if($is_pdo){ + $sth->closeCursor(); + }else{ + mysqli_free_result($sth); + } +} + +function _db_num_rows($sth){ + global $is_pdo; + if($is_pdo){ + return $sth->rowCount(); + }else{ + return mysqli_num_rows($sth); + } +} + +function _db_field_count($dbh,$sth){ + global $is_pdo; + if($is_pdo){ + return $sth->columnCount(); + }else{ + return mysqli_num_fields($sth); + } +} + +function _db_fetch_field($sth,$col){ + global $is_pdo; + if($is_pdo){ + $metadata=$sth->getColumnMeta($col); + $ret=new stdClass(); + $ret->name=$metadata["name"]; + return $ret; + }else{ + return mysqli_fetch_field($sth); + } +} + +function _db_connect_error(){ + global $is_pdo,$pdo_err; + if($is_pdo){ + return $pdo_err; + }else{ + return mysqli_connect_error(); + } +} + function db_connect($nodie=0){ global $dbh,$DB,$err_msg; @@ -677,10 +689,10 @@ function db_connect($nodie=0){ mysqli_ssl_set($dbh,$DB['ssl_key'],$DB['ssl_cert'],$DB['ssl_ca'],NULL,NULL); if (!mysqli_real_connect($dbh,$DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so,MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT)) $dbh=null; }else{#non-ssl - $dbh=_mysqli_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); + $dbh=_db_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); } if (!$dbh) { - $err_msg='Cannot connect to the database because: '._mysqli_connect_error(); + $err_msg='Cannot connect to the database because: '._db_connect_error(); if (!$nodie) die($err_msg); }else{ if ($DB['chset']) db_query("SET NAMES ".$DB['chset']); @@ -692,7 +704,7 @@ function db_connect($nodie=0){ function db_checkconnect($dbh1=NULL, $skiperr=0){ global $dbh; if (!$dbh1) $dbh1=&$dbh; - if (!$dbh1 or !_mysqli_ping($dbh1)) { + if (!$dbh1 or !db_ping($dbh1)) { db_connect($skiperr); $dbh1=&$dbh; } @@ -712,36 +724,36 @@ function dbq($s){ function db_query($sql, $dbh1=NULL, $skiperr=0, $resmod=MYSQLI_STORE_RESULT){ $dbh1=db_checkconnect($dbh1, $skiperr); - if($dbh1) $sth=_mysqli_query($dbh1, $sql, $resmod); + if($dbh1) $sth=_db_query($dbh1, $sql, $resmod); if (!$sth && $skiperr) return; if (!$sth) die("Error in DB operation:
\n".mysqli_error($dbh1)."
\n$sql"); return $sth; } function db_array($sql, $dbh1=NULL, $skiperr=0, $isnum=0){#array of rows - global $api_type; - if ($api_type != 1 && is_null($dbh1)) return null; + global $is_pdo; + if ($is_pdo != 1 && is_null($dbh1)) return null; $sth=db_query($sql, $dbh1, $skiperr, MYSQLI_USE_RESULT); if (!$sth) return; $res=array(); if ($isnum){ - while($row=_mysqli_fetch_row($sth)) $res[]=$row; + while($row=db_fetch_row($sth)) $res[]=$row; }else{ - while($row=_mysqli_fetch_assoc($sth)) $res[]=$row; + while($row=db_fetch_assoc($sth)) $res[]=$row; } - _mysqli_free_result($sth); + _db_free($sth); return $res; } function db_row($sql){ $sth=db_query($sql); - return _mysqli_fetch_assoc($sth); + return db_fetch_assoc($sth); } function db_value($sql,$dbh1=NULL,$skiperr=0){ $sth=db_query($sql,$dbh1,$skiperr); if (!$sth) return; - $row=_mysqli_fetch_row($sth); + $row=db_fetch_row($sth); return $row[0]; } @@ -984,14 +996,14 @@ function do_export(){ if ($DB['chset']=='utf8mb4') ex_w($BOM); $sth=db_query("select * from `$t[0]`",NULL,0,MYSQLI_USE_RESULT); - $fn=_mysqli_field_count($dbh, $sth); + $fn=_db_field_count($dbh, $sth); for($i=0;$i<$fn;$i++){ - $m=_mysqli_fetch_field($sth, $i); + $m=_db_fetch_field($sth, $i); ex_w(qstr($m->name).(($i<$fn-1)?",":"")); } ex_w($D); - while($row=_mysqli_fetch_row($sth)) ex_w(to_csv_row($row)); - _mysqli_free_result($sth); + while($row=db_fetch_row($sth)) ex_w(to_csv_row($row)); + _db_free($sth); }else{ ex_start('.sql'); ex_hdr($ctp?$ctp:'text/plain',"$DB[db]".(($ct==1&&$t[0])?".$t[0]":(($ct>1)?'.'.$ct.'tables':'')).".sql$aext"); @@ -1001,7 +1013,7 @@ function do_export(){ ex_w("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;$D$D"); $sth=db_query("show full tables from `$DB[db]`"); - while($row=_mysqli_fetch_row($sth)){ + while($row=db_fetch_row($sth)){ if (!$rt||array_key_exists($row[0],$th)) do_export_table($row[0],$row[1],$MAXI); } @@ -1019,7 +1031,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ if($_REQUEST['s']){ $sth=db_query("show create table `$t`"); - $row=_mysqli_fetch_row($sth); + $row=db_fetch_row($sth); $ct=preg_replace("/\n\r|\r\n|\n|\r/",$D,$row[1]); ex_w("DROP TABLE IF EXISTS `$t`;$D$ct;$D$D"); } @@ -1028,7 +1040,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ $exsql=''; ex_w("/*!40000 ALTER TABLE `$t` DISABLE KEYS */;$D"); $sth=db_query("select * from `$t`",NULL,0,MYSQLI_USE_RESULT); - while($row=_mysqli_fetch_row($sth)){ + while($row=db_fetch_row($sth)){ $values=''; foreach($row as $v) $values.=(($values)?',':'').dbq($v); $exsql.=(($exsql)?',':'')."(".$values.")"; @@ -1036,7 +1048,7 @@ function do_export_table($t='',$tt='',$MAXI=838860){ ex_w("INSERT INTO `$t` VALUES $exsql;$D");$exsql=''; } } - _mysqli_free_result($sth); + _db_free($sth); if ($exsql) ex_w("INSERT INTO `$t` VALUES $exsql;$D"); ex_w("/*!40000 ALTER TABLE `$t` ENABLE KEYS */;$D$D"); }