PMA_getUvaCondition():
- fixed missing $analyzed_sql (partly bug #1431615) - added table names to column names (partly bug #1431615) - simplified search for alias
This commit is contained in:
@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2006-02-19 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||
* libraries/common.lib.php PMA_getUvaCondition():
|
||||
- fixed missing $analyzed_sql (partly bug #1431615)
|
||||
- added table names to column names (partly bug #1431615)
|
||||
- simplified search for alias
|
||||
|
||||
2006-02-18 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* tbl_change.php: bug #1415465, undefined $sql_query
|
||||
* libraries/common.lib.php: bug #1377215, errors with E_STRICT
|
||||
|
@@ -299,7 +299,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink,
|
||||
$dblist[] = $uva_db;
|
||||
$uva_mydbs[$uva_db] = 0;
|
||||
} elseif (!isset($dblist[$uva_db])) {
|
||||
foreach ($uva_mydbs AS $uva_matchpattern => $uva_value) {
|
||||
foreach ($uva_mydbs as $uva_matchpattern => $uva_value) {
|
||||
// loic1: fixed bad regexp
|
||||
// TODO: db names may contain characters
|
||||
// that are regexp instructions
|
||||
@@ -460,7 +460,7 @@ function PMA_array_merge_recursive()
|
||||
if (!is_array($args[0]) || !is_array($args[1])) {
|
||||
return $args[1];
|
||||
}
|
||||
foreach ($args[1] AS $key2 => $value2) {
|
||||
foreach ($args[1] as $key2 => $value2) {
|
||||
if (isset($args[0][$key2]) && !is_int($key2)) {
|
||||
$args[0][$key2] = PMA_array_merge_recursive($args[0][$key2],
|
||||
$value2);
|
||||
@@ -1241,7 +1241,7 @@ if (!defined('PMA_MINIMUM_COMMON')) {
|
||||
|
||||
if (is_array($a_name)) {
|
||||
$result = array();
|
||||
foreach ($a_name AS $key => $val) {
|
||||
foreach ($a_name as $key => $val) {
|
||||
$result[$key] = '`' . $val . '`';
|
||||
}
|
||||
return $result;
|
||||
@@ -2093,7 +2093,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
$subname_close = ']';
|
||||
$submit_name = ' name="usesubform[' . $GLOBALS['subform_counter'] . ']"';
|
||||
}
|
||||
foreach ($query_parts AS $query_pair) {
|
||||
foreach ($query_parts as $query_pair) {
|
||||
list($eachvar, $eachval) = explode('=', $query_pair);
|
||||
$ret .= '<input type="hidden" name="' . $subname_open . $eachvar
|
||||
. $subname_close . '" value="'
|
||||
@@ -2235,7 +2235,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
$found_error = false;
|
||||
$error_message = '';
|
||||
|
||||
foreach ($params AS $param) {
|
||||
foreach ($params as $param) {
|
||||
if ($request && $param != 'db' && $param != 'table') {
|
||||
$checked_special = true;
|
||||
}
|
||||
@@ -2257,10 +2257,18 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
/**
|
||||
* Function to generate unique condition for specified row.
|
||||
*
|
||||
* @param resource handle for current query
|
||||
* @param integer number of fields
|
||||
* @param array meta information about fields
|
||||
* @param array current row
|
||||
* @uses PMA_MYSQL_INT_VERSION
|
||||
* @uses $GLOBALS['analyzed_sql'][0]
|
||||
* @uses PMA_DBI_field_flags()
|
||||
* @uses PMA_backquote()
|
||||
* @uses PMA_sqlAddslashes()
|
||||
* @uses stristr()
|
||||
* @uses bin2hex()
|
||||
* @uses preg_replace()
|
||||
* @param resource $handle current query result
|
||||
* @param integer $fields_cnt number of fields
|
||||
* @param array $fields_meta meta information about fields
|
||||
* @param array $row current row
|
||||
*
|
||||
* @access public
|
||||
* @author Michal Cihar (michal@cihar.com)
|
||||
@@ -2274,36 +2282,46 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
|
||||
for ($i = 0; $i < $fields_cnt; ++$i) {
|
||||
$field_flags = PMA_DBI_field_flags($handle, $i);
|
||||
$meta = $fields_meta[$i];
|
||||
$meta = $fields_meta[$i];
|
||||
|
||||
// do not use an alias in a condition
|
||||
$column_for_condition = $meta->name;
|
||||
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
|
||||
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
|
||||
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
|
||||
if (strlen($alias)) {
|
||||
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
|
||||
if ($alias == $meta->name) {
|
||||
$column_for_condition = $true_column;
|
||||
if (! isset($meta->orgname)) {
|
||||
$meta->orgname = $meta->name;
|
||||
|
||||
if (isset($GLOBALS['analyzed_sql'][0]['select_expr'])
|
||||
&& is_array($GLOBALS['analyzed_sql'][0]['select_expr'])) {
|
||||
foreach ($GLOBALS['analyzed_sql'][0]['select_expr']
|
||||
as $select_expr) {
|
||||
// need (string) === (string)
|
||||
// '' !== 0 but '' == 0
|
||||
if ((string) $select_expr['alias'] === (string) $meta->name) {
|
||||
$meta->orgname = $select_expr['column'];
|
||||
break;
|
||||
} // end if
|
||||
} // end if
|
||||
} // end while
|
||||
} // end foreach
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// to fix the bug where float fields (primary or not)
|
||||
// can't be matched because of the imprecision of
|
||||
// floating comparison, use CONCAT
|
||||
// (also, the syntax "CONCAT(field) IS NULL"
|
||||
// that we need on the next "if" will work)
|
||||
if ($meta->type == 'real') {
|
||||
$condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') ';
|
||||
$condition = ' CONCAT(' . PMA_backquote($meta->table) . '.'
|
||||
. PMA_backquote($meta->orgname) . ') ';
|
||||
} else {
|
||||
// string and blob fields have to be converted using
|
||||
// the system character set (always utf8) since
|
||||
// mysql4.1 can use different charset for fields.
|
||||
if (PMA_MYSQL_INT_VERSION >= 40100 && ($meta->type == 'string' || $meta->type == 'blob')) {
|
||||
$condition = ' CONVERT(' . PMA_backquote($column_for_condition) . ' USING utf8) ';
|
||||
if (PMA_MYSQL_INT_VERSION >= 40100
|
||||
&& ($meta->type == 'string' || $meta->type == 'blob')) {
|
||||
$condition = ' CONVERT(' . PMA_backquote($meta->table) . '.'
|
||||
. PMA_backquote($meta->orgname) . ' USING utf8) ';
|
||||
} else {
|
||||
$condition = ' ' . PMA_backquote($column_for_condition) . ' ';
|
||||
$condition = ' ' . PMA_backquote($meta->table) . '.'
|
||||
. PMA_backquote($meta->orgname) . ' ';
|
||||
}
|
||||
} // end if... else...
|
||||
|
||||
@@ -2320,12 +2338,14 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
// use a CAST if possible, to avoid problems
|
||||
// if the field contains wildcard characters % or _
|
||||
if (PMA_MYSQL_INT_VERSION < 40002) {
|
||||
$condition .= 'LIKE 0x' . bin2hex($row[$i]). ' AND';
|
||||
$condition .= 'LIKE 0x' . bin2hex($row[$i]) . ' AND';
|
||||
} else {
|
||||
$condition .= '= CAST(0x' . bin2hex($row[$i]). ' AS BINARY) AND';
|
||||
$condition .= '= CAST(0x' . bin2hex($row[$i])
|
||||
. ' AS BINARY) AND';
|
||||
}
|
||||
} else {
|
||||
$condition .= '= \'' . PMA_sqlAddslashes($row[$i], false, true) . '\' AND';
|
||||
$condition .= '= \''
|
||||
. PMA_sqlAddslashes($row[$i], false, true) . '\' AND';
|
||||
}
|
||||
}
|
||||
if ($meta->primary_key > 0) {
|
||||
@@ -2469,7 +2489,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm
|
||||
$pages = array_unique($pages);
|
||||
}
|
||||
|
||||
foreach ($pages AS $i) {
|
||||
foreach ($pages as $i) {
|
||||
if ($i == $pageNow) {
|
||||
$selected = 'selected="selected" style="font-weight: bold"';
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user