1
0
Fork 0

switched to mysqli_select_db

the emulation of mysql_select_db with the USE statement did not quote the table name so table names which need quotation (which contain dashes for example) were not handled correctly
the emualtion is not needed, see https://github.com/philip/MySQLConverterTool/issues/20
Dieser Commit ist enthalten in:
e-dschungel 2017-01-29 21:42:37 +01:00
Ursprung cd2675d498
Commit 72998c0df3
10 geänderte Dateien mit 21 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -355,7 +355,7 @@ if (isset($_POST['save']))
{
if (MSD_mysql_connect())
{
$res=@((bool)mysqli_query($config['dbconnection'], "USE " . $to_add));
$res=@mysqli_select_db($config['dbconnection'], $to_add));
if (!$res === false)
{
$databases['Name'][] = $to_add;
@ -1002,4 +1002,4 @@ if (( $showVP ) || ( !isset($databases['Name']) ) || ( isset($databases['name'])
echo '</script>';
echo MSDFooter();
$_SESSION['config']=$config;
ob_end_flush();
ob_end_flush();

Datei anzeigen

@ -173,7 +173,7 @@ function SetDefault($load_default = false)
$a = 0;
for ($i = 0; $i < count($found_dbs); $i++) {
$found_db = $found_dbs[$i];
$use = @((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $found_db));
$use = @mysqli_select_db($GLOBALS["___mysqli_ston"], $found_db);
if ($use) {
if (isset($old_db) && $found_db == $old_db) {
$databases['db_selected_index'] = $a;
@ -799,4 +799,4 @@ function db_escape($string)
return $string;
}
?>
?>

Datei anzeigen

@ -129,7 +129,7 @@ function get_def($db,$table,$withdata=1)
}
else
$def.="DROP TABLE IF EXISTS `$table`;\n";
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $db));
mysqli_select_db($GLOBALS["___mysqli_ston"], $db);
$result=mysqli_query($config['dbconnection'], 'SHOW CREATE TABLE `'.$table.'`');
$row=@mysqli_fetch_row($result);
if ($row===false) return false;
@ -152,7 +152,7 @@ function get_content($db,$table)
$table_ready=0;
$query='SELECT * FROM `'.$table.'` LIMIT '.$dump['zeilen_offset'].','.($dump['restzeilen']+1);
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $db));
mysqli_select_db($GLOBALS["___mysqli_ston"], $db);
$result=mysqli_query($config['dbconnection'], $query);
$ergebnisse=@mysqli_num_rows($result);
if ($ergebnisse!==false)
@ -275,7 +275,7 @@ function ExecuteCommand($when)
if (substr(strtolower($cd),0,7)!='system:')
{
$cad=array();
@((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$dump['dbindex']]));
mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['Name'][$dump['dbindex']]);
if (strpos($cd,';'))
{
$cad=explode(';',$cd);

Datei anzeigen

@ -116,7 +116,7 @@ function DBDetailInfo($index)
$databases['Detailinfo']['tables'] = $databases['Detailinfo']['records'] = $databases['Detailinfo']['size'] = 0;
MSD_mysql_connect();
if (isset($databases['Name'][$index])) {
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$index]));
mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['Name'][$index]);
$databases['Detailinfo']['Name'] = $databases['Name'][$index];
$res = @mysqli_query(
$GLOBALS["___mysqli_ston"],
@ -1420,4 +1420,4 @@ function fetchFileDataFromURL($url)
return $in;
}
?>
?>

Datei anzeigen

@ -226,7 +226,7 @@ function DB_Copy($source, $destination, $drop_source=0, $insert_data=1)
return false;
}
}
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $destination));
mysqli_select_db($GLOBALS["___mysqli_ston"], $destination);
$res=MSD_DoSQL($SQL_Array);
if ($drop_source == 1 && $res) MSD_query("DROP DATABASE `$source`;");
return $res;

Datei anzeigen

@ -23,7 +23,7 @@ for ($i=0; $i<count($databases['Name']); $i++)
}
if (isset($_POST['optimize'.$i]))
{
((bool)mysqli_query( $config['dbconnection'], "USE " . $databases['Name'][$i]));
mysqli_select_db($config['dbconnection'], $databases['Name'][$i]);
$res=mysqli_query($config['dbconnection'], 'SHOW TABLES FROM `'.$databases['Name'][$i].'`');
$tabellen='';
WHILE ($row=mysqli_fetch_row($res))
@ -63,7 +63,7 @@ for ($i=0; $i<count($databases['Name']); $i++)
if ($i==$databases['db_selected_index']) $rowclass="dbrowsel";
//gibts die Datenbank überhaupt?
if (!((bool)mysqli_query($config['dbconnection'], "USE " . $databases['Name'][$i])))
if (!mysqli_select_db($config['dbconnection'], $databases['Name'][$i]))
{
$tpl->assign_block_vars('DB_NOT_FOUND',array(
'ROWCLASS' => $rowclass,
@ -73,7 +73,7 @@ for ($i=0; $i<count($databases['Name']); $i++)
}
else
{
((bool)mysqli_query($config['dbconnection'], "USE " . $databases['Name'][$i]));
mysqli_select_db($config['dbconnection'], $databases['Name'][$i]);
$tabellen=mysqli_query($config['dbconnection'], 'SHOW TABLES FROM `'.$databases['Name'][$i].'`');
$num_tables=mysqli_num_rows($tabellen);
$tpl->assign_block_vars('ROW',array(
@ -102,7 +102,7 @@ if (isset($_GET['dbid']))
$numrows=0;
$res=@mysqli_query($GLOBALS["___mysqli_ston"], "SHOW TABLE STATUS FROM `".$databases['Name'][$dbid]."`");
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$dbid]));
mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['Name'][$dbid]);
if ($res) $numrows=mysqli_num_rows($res);
$tpl->assign_vars(array(
'DB_NAME' => $databases['Name'][$dbid],

Datei anzeigen

@ -403,7 +403,7 @@ function getDBInfos()
}
if ($config['optimize_tables_beforedump'] == 1 && $dump['table_offset'] == -1
&& $databases['Name'][$dump['dbindex']]!='information_schema') {
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$dump['dbindex']]));
mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['Name'][$dump['dbindex']]);
$opt = 'OPTIMIZE TABLE `' . $row['Name'] . '`';
$res = mysqli_query($GLOBALS["___mysqli_ston"], 'OPTIMIZE TABLE `' . $row['Name'] . '`');
if ($res === false) {

Datei anzeigen

@ -278,7 +278,7 @@ if (isset($_POST['newfield_posted']))
$fields_infos=getFieldinfos($databases['Name'][$dbid],$table_edit_name);
}
}
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['Name'][$dbid]));
mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['Name'][$dbid]);
$sqlt="SHOW TABLE STATUS FROM `".$databases['Name'][$dbid]."` ;";
$res=MSD_query($sqlt);
$anz_tabellen=mysqli_num_rows($res);
@ -592,4 +592,4 @@ if ($table_edit_name!="")
echo '<br><input name="setNewKeys" type="submit" value="'.$lang['L_SAVE'].'" class="Formbutton">';
echo '</form>';
}
}
}

Datei anzeigen

@ -78,7 +78,7 @@ $pageheader=MSDheader().headline($lang['L_RESTORE']);
$aus1=$page_parameter='';
$RestoreFertig=$eingetragen=$dauer=$filegroesse=0;
MSD_mysql_connect($restore['dump_encoding'],true,$restore['actual_table']);
@((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $databases['db_actual'])) or die($lang['L_DB_SELECT_ERROR'].$databases['db_actual'].$lang['L_DB_SELECT_ERROR2']);
@mysqli_select_db($GLOBALS["___mysqli_ston"], $databases['db_actual']) or die($lang['L_DB_SELECT_ERROR'].$databases['db_actual'].$lang['L_DB_SELECT_ERROR2']);
// open backup file
$restore['filehandle']=($restore['compressed']==1) ? gzopen($config['paths']['backup'].$restore['filename'],'r') : fopen($config['paths']['backup'].$restore['filename'],'r');
@ -306,4 +306,4 @@ else
}
echo $complete_page;
ob_end_flush();
?>
?>

Datei anzeigen

@ -124,7 +124,7 @@ if ($sql_to_display_data==1)
if (isset($_POST['tableselect'])&&$_POST['tableselect']!='1') $tablename=$_POST['tableselect'];
MSD_mysql_connect();
((bool)mysqli_query($config['dbconnection'], "USE " . $db));
mysqli_select_db($config['dbconnection'], $db);
///*** EDIT / UPDATES / INSERTS ***///
///*** ***///
@ -295,4 +295,4 @@ function FormHiddenParams()
$s.='<input type="hidden" name="order" value="'.$order.'">';
$s.='<input type="hidden" name="orderdir" value="'.$orderdir.'">';
return $s;
}
}