removed use charset_connection
This commit is contained in:
@@ -162,21 +162,15 @@ if (isset($_REQUEST['submit_search'])) {
|
||||
*/
|
||||
function PMA_getSearchSqls($table, $field, $search_str, $search_option)
|
||||
{
|
||||
global $err_url, $charset_connection;
|
||||
global $err_url;
|
||||
|
||||
// Statement types
|
||||
$sqlstr_select = 'SELECT';
|
||||
$sqlstr_delete = 'DELETE';
|
||||
|
||||
// Fields to select
|
||||
$res = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']) . ';');
|
||||
while ($current = PMA_DBI_fetch_assoc($res)) {
|
||||
list($current['Charset']) = explode('_', $current['Collation']);
|
||||
$current['Field'] = PMA_backquote($current['Field']);
|
||||
$tblfields[] = $current;
|
||||
} // while
|
||||
PMA_DBI_free_result($res);
|
||||
unset($current, $res);
|
||||
$tblfields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']),
|
||||
null, 'Field');
|
||||
|
||||
// Table to use
|
||||
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
|
||||
@@ -185,36 +179,23 @@ if (isset($_REQUEST['submit_search'])) {
|
||||
$search_wds_cnt = count($search_words);
|
||||
|
||||
$like_or_regex = (($search_option == 4) ? 'REGEXP' : 'LIKE');
|
||||
$automatic_wildcard = (($search_option <3) ? '%' : '');
|
||||
$automatic_wildcard = (($search_option < 3) ? '%' : '');
|
||||
|
||||
$fieldslikevalues = array();
|
||||
foreach ($search_words as $search_word) {
|
||||
// Eliminates empty values
|
||||
// In MySQL 4.1, if a field has no collation we get NULL in Charset
|
||||
// but in MySQL 5.0.x we get ''
|
||||
if (strlen($search_word) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$thefieldlikevalue = array();
|
||||
foreach ($tblfields as $tblfield) {
|
||||
if ($tblfield['Charset'] != $charset_connection
|
||||
&& $tblfield['Charset'] != 'NULL'
|
||||
&& $tblfield['Charset'] != '') {
|
||||
$prefix = 'CONVERT(_utf8 ';
|
||||
$suffix = ' USING ' . $tblfield['Charset'] . ') COLLATE ' . $tblfield['Collation'];
|
||||
} else {
|
||||
$prefix = $suffix = '';
|
||||
}
|
||||
if ((!isset($field)) || (strlen($field) == 0) || ($tblfield['Field'] == PMA_backquote($field))) {
|
||||
$thefieldlikevalue[] = $tblfield['Field']
|
||||
if (! isset($field) || strlen($field) == 0 || $tblfield == $field) {
|
||||
$thefieldlikevalue[] = PMA_backquote($tblfield)
|
||||
. ' ' . $like_or_regex . ' '
|
||||
. $prefix
|
||||
. "'"
|
||||
. $automatic_wildcard
|
||||
. "'" . $automatic_wildcard
|
||||
. $search_word
|
||||
. $automatic_wildcard . "'"
|
||||
. $suffix;
|
||||
. $automatic_wildcard . "'";
|
||||
}
|
||||
} // end for
|
||||
|
||||
|
@@ -786,7 +786,6 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null
|
||||
* @uses PMA_DBI_query()
|
||||
* @uses PMA_DBI_get_variable()
|
||||
* @uses $GLOBALS['collation_connection']
|
||||
* @uses $GLOBALS['charset_connection']
|
||||
* @uses $GLOBALS['available_languages']
|
||||
* @uses $GLOBALS['mysql_charset_map']
|
||||
* @uses $GLOBALS['charset']
|
||||
|
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Handles table search tab
|
||||
*
|
||||
* display table search form, create SQL query from form data
|
||||
* and include sql.php to execute it
|
||||
*
|
||||
* @todo display search form again if no results from previous search
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
@@ -357,7 +362,7 @@ else {
|
||||
list($charsets[$i]) = explode('_', $collations[$i]);
|
||||
if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) {
|
||||
$fields[$i] = '';
|
||||
$w[] = PMA_backquote(urldecode($names[$i])) . ' ' . $func_type;
|
||||
$w[] = PMA_backquote($names[$i]) . ' ' . $func_type;
|
||||
|
||||
} elseif (strncasecmp($types[$i], 'enum', 4) == 0) {
|
||||
if (!empty($fields[$i])) {
|
||||
@@ -380,20 +385,11 @@ else {
|
||||
$parens_close = '';
|
||||
}
|
||||
$enum_where = '\'' . PMA_sqlAddslashes($fields[$i][0]) . '\'';
|
||||
if ($charsets[$i] != $charset_connection) {
|
||||
$enum_where = 'CONVERT(_utf8 ' . $enum_where . ' USING ' . $charsets[$i] . ') COLLATE ' . $collations[$i];
|
||||
}
|
||||
for ($e = 1; $e < $enum_selected_count; $e++) {
|
||||
$enum_where .= ', ';
|
||||
$tmp_literal = '\'' . PMA_sqlAddslashes($fields[$i][$e]) . '\'';
|
||||
if ($charsets[$i] != $charset_connection) {
|
||||
$tmp_literal = 'CONVERT(_utf8 ' . $tmp_literal . ' USING ' . $charsets[$i] . ') COLLATE ' . $collations[$i];
|
||||
}
|
||||
$enum_where .= $tmp_literal;
|
||||
unset($tmp_literal);
|
||||
$enum_where .= ', \'' . PMA_sqlAddslashes($fields[$i][$e]) . '\'';
|
||||
}
|
||||
|
||||
$w[] = PMA_backquote(urldecode($names[$i])) . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
$w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close;
|
||||
}
|
||||
|
||||
} elseif ($fields[$i] != '') {
|
||||
@@ -406,23 +402,12 @@ else {
|
||||
$quot = '';
|
||||
}
|
||||
|
||||
// Make query independant from the selected connection charset.
|
||||
// But if the field's type is VARBINARY, it has no charset
|
||||
// and $charsets[$i] is empty, so we cannot generate a CONVERT
|
||||
|
||||
if (!empty($charsets[$i]) && $charsets[$i] != $charset_connection && preg_match('@char|binary|blob|text|set@i', $types[$i])) {
|
||||
$prefix = 'CONVERT(_utf8 ';
|
||||
$suffix = ' USING ' . $charsets[$i] . ') COLLATE ' . $collations[$i];
|
||||
} else {
|
||||
$prefix = $suffix = '';
|
||||
}
|
||||
|
||||
// LIKE %...%
|
||||
if ($func_type == 'LIKE %...%') {
|
||||
$func_type = 'LIKE';
|
||||
$fields[$i] = '%' . $fields[$i] . '%';
|
||||
}
|
||||
$w[] = PMA_backquote(urldecode($names[$i])) . ' ' . $func_type . ' ' . $prefix . $quot . PMA_sqlAddslashes($fields[$i]) . $quot . $suffix;
|
||||
$w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields[$i]) . $quot;
|
||||
|
||||
} // end if
|
||||
} // end for
|
||||
@@ -433,9 +418,10 @@ else {
|
||||
} // end if
|
||||
|
||||
if ($orderField != '--nil--') {
|
||||
$sql_query .= ' ORDER BY ' . PMA_backquote(urldecode($orderField)) . ' ' . $order;
|
||||
$sql_query .= ' ORDER BY ' . PMA_backquote($orderField) . ' ' . $order;
|
||||
} // end if
|
||||
include './sql.php';
|
||||
|
||||
require './sql.php';
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user