lib.inc.php3, db_readdump.php3:
removed expand_sql_query() as no longer needed
This commit is contained in:
@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2001-08-27 Robin Johnson <robbat2@orbis-terrarum.net>
|
||||||
|
* lib.inc.php3, db_readdump.php3
|
||||||
|
- removed expand_sql_query() as no longer needed
|
||||||
|
|
||||||
2001-08-27 Olivier M<>ller <om@omnis.ch>
|
2001-08-27 Olivier M<>ller <om@omnis.ch>
|
||||||
* tbl_replace.php3: fixed the fact that the function were ignored if the
|
* tbl_replace.php3: fixed the fact that the function were ignored if the
|
||||||
data remained unchanged.
|
data remained unchanged.
|
||||||
|
@@ -97,11 +97,6 @@ if ($sql_query != '') {
|
|||||||
$pieces = split_sql_file($sql_query, ';');
|
$pieces = split_sql_file($sql_query, ';');
|
||||||
$pieces_count = count($pieces);
|
$pieces_count = count($pieces);
|
||||||
|
|
||||||
// Handles table aliases
|
|
||||||
for ($i = 0; $i < $pieces_count; $i++) {
|
|
||||||
$pieces[$i] = expand_sql_query($pieces[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only one query to run
|
// Only one query to run
|
||||||
if ($pieces_count == 1 && !empty($pieces[0]) && $view_bookmark == 0) {
|
if ($pieces_count == 1 && !empty($pieces[0]) && $view_bookmark == 0) {
|
||||||
$sql_query = trim($pieces[0]);
|
$sql_query = trim($pieces[0]);
|
||||||
|
104
lib.inc.php3
104
lib.inc.php3
@@ -703,110 +703,6 @@ window.parent.frames['nav'].location.replace('<?php echo $reload_url; ?>');
|
|||||||
return array($return_value, $unit);
|
return array($return_value, $unit);
|
||||||
} // end of the 'format_byte_down' function
|
} // end of the 'format_byte_down' function
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----- Functions used to display records returned by a sql query ----- */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expands table alias in SQL queries
|
|
||||||
*
|
|
||||||
* @param string a single sql query
|
|
||||||
*
|
|
||||||
* @return string the expanded SQL query
|
|
||||||
*
|
|
||||||
* @author Robin Johnson
|
|
||||||
*
|
|
||||||
* @version 1.1 - 10th August 2001
|
|
||||||
*/
|
|
||||||
function expand_sql_query($sql)
|
|
||||||
{
|
|
||||||
$sql = trim($sql);
|
|
||||||
$arr = explode(' ', $sql);
|
|
||||||
if (strtoupper($arr[0]) != 'SELECT') {
|
|
||||||
return $sql;
|
|
||||||
}
|
|
||||||
$start_table_ref = FALSE;
|
|
||||||
$end_table_ref = FALSE;
|
|
||||||
|
|
||||||
// Finds which block of text has the table reference data
|
|
||||||
for ($i = 0; $i < count($arr); $i++) {
|
|
||||||
$tmp = trim(strtoupper($arr[$i]));
|
|
||||||
if ($tmp == 'FROM') {
|
|
||||||
$start_table_ref = $i + 1;
|
|
||||||
}
|
|
||||||
else if ($tmp == 'WHERE' || $tmp == 'GROUP' || $tmp == 'HAVING' || $tmp == 'ORDER'
|
|
||||||
|| $tmp == 'LIMIT' || $tmp == 'PROCEDURE' || $tmp == 'FOR' || $tmp == 'BY'
|
|
||||||
|| $tmp == 'UPDATE' || $tmp == 'LOCK' || $tmp == 'IN' || $tmp == 'SHARE'
|
|
||||||
|| $tmp == 'MODE') {
|
|
||||||
// We want only the first one
|
|
||||||
if (!$end_table_ref) {
|
|
||||||
$end_table_ref = $i - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end for
|
|
||||||
// In case the table reference was the last thing
|
|
||||||
if (!$end_table_ref) {
|
|
||||||
$end_table_ref = count($arr) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles the table reference data
|
|
||||||
// First put it back together
|
|
||||||
$table_ref_data = '';
|
|
||||||
for ($i = $start_table_ref; $i <= $end_table_ref; $i++) {
|
|
||||||
$table_ref_data .= ' ' . $arr[$i];
|
|
||||||
} // end for
|
|
||||||
|
|
||||||
// Cleans out the extra spaces
|
|
||||||
$table_ref_data = trim($table_ref_data);
|
|
||||||
|
|
||||||
// Cleans up a bit
|
|
||||||
unset($arr);
|
|
||||||
unset($tmp);
|
|
||||||
unset($i);
|
|
||||||
|
|
||||||
// Breaks it apart into each table used
|
|
||||||
$arr = explode(',', $table_ref_data);
|
|
||||||
|
|
||||||
// Handles each table used
|
|
||||||
reset($arr);
|
|
||||||
while (list(, $table) = each ($arr)) {
|
|
||||||
$table = trim($table);
|
|
||||||
if (isset($data)) {
|
|
||||||
unset($data);
|
|
||||||
}
|
|
||||||
$data = explode(' ', $table); //will have at most 3 items
|
|
||||||
if (isset($data_count)) {
|
|
||||||
unset($data_count);
|
|
||||||
}
|
|
||||||
$data_count = count($data);
|
|
||||||
if (isset($match)) {
|
|
||||||
unset($match);
|
|
||||||
}
|
|
||||||
if ($data_count == 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Checks with 'as' keyword specified...
|
|
||||||
if ($data_count == 3) {
|
|
||||||
$data[1] = $data[2];
|
|
||||||
$match = $data[0] . ' as ' . $data[1];
|
|
||||||
}
|
|
||||||
// ... and now in form "departments d"
|
|
||||||
if ($data_count >= 2) {
|
|
||||||
$sql = eregi_replace(
|
|
||||||
'([^a-zA-Z0-9])' . $data[1] . '\.',
|
|
||||||
'\1 ' . $data[0] . '.',
|
|
||||||
$sql);
|
|
||||||
if (!isset($match)) {
|
|
||||||
$match = $data[0] . ' ' . $data[1];
|
|
||||||
}
|
|
||||||
$sql = str_replace($match, ' ' . $data[0], $sql);
|
|
||||||
} // end if
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
} // end of the 'expand_sql_query()' function
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a navigation bar to browse among the results of a sql query
|
* Displays a navigation bar to browse among the results of a sql query
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user