removed use charset_connection

This commit is contained in:
Sebastian Mendel
2008-01-21 10:05:36 +00:00
parent 2c87a4715e
commit e3672d6a5f
3 changed files with 23 additions and 57 deletions

View File

@@ -100,7 +100,7 @@ if (empty($_REQUEST['search_str']) || ! is_string($_REQUEST['search_str'])) {
// For "as regular expression" (search option 4), we should not treat // For "as regular expression" (search option 4), we should not treat
// this as an expression that contains a LIKE (second parameter of // this as an expression that contains a LIKE (second parameter of
// PMA_sqlAddslashes()). // PMA_sqlAddslashes()).
// //
// Usage example: If user is seaching for a literal $ in a regexp search, // Usage example: If user is seaching for a literal $ in a regexp search,
// he should enter \$ as the value. // he should enter \$ as the value.
$search_str = PMA_sqlAddslashes($_REQUEST['search_str'], ($search_option == 4 ? false : true)); $search_str = PMA_sqlAddslashes($_REQUEST['search_str'], ($search_option == 4 ? false : true));
@@ -150,7 +150,7 @@ if (isset($_REQUEST['submit_search'])) {
* count * count
* strlen * strlen
* @param string the table name * @param string the table name
* @param string restrict the search to this field * @param string restrict the search to this field
* @param string the string to search * @param string the string to search
* @param integer type of search (1 -> 1 word at least, 2 -> all words, * @param integer type of search (1 -> 1 word at least, 2 -> all words,
* 3 -> exact string, 4 -> regexp) * 3 -> exact string, 4 -> regexp)
@@ -162,21 +162,15 @@ if (isset($_REQUEST['submit_search'])) {
*/ */
function PMA_getSearchSqls($table, $field, $search_str, $search_option) function PMA_getSearchSqls($table, $field, $search_str, $search_option)
{ {
global $err_url, $charset_connection; global $err_url;
// Statement types // Statement types
$sqlstr_select = 'SELECT'; $sqlstr_select = 'SELECT';
$sqlstr_delete = 'DELETE'; $sqlstr_delete = 'DELETE';
// Fields to select // Fields to select
$res = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']) . ';'); $tblfields = PMA_DBI_fetch_result('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']),
while ($current = PMA_DBI_fetch_assoc($res)) { null, 'Field');
list($current['Charset']) = explode('_', $current['Collation']);
$current['Field'] = PMA_backquote($current['Field']);
$tblfields[] = $current;
} // while
PMA_DBI_free_result($res);
unset($current, $res);
// Table to use // Table to use
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table); $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); $search_wds_cnt = count($search_words);
$like_or_regex = (($search_option == 4) ? 'REGEXP' : 'LIKE'); $like_or_regex = (($search_option == 4) ? 'REGEXP' : 'LIKE');
$automatic_wildcard = (($search_option <3) ? '%' : ''); $automatic_wildcard = (($search_option < 3) ? '%' : '');
$fieldslikevalues = array(); $fieldslikevalues = array();
foreach ($search_words as $search_word) { foreach ($search_words as $search_word) {
// Eliminates empty values // 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) { if (strlen($search_word) === 0) {
continue; continue;
} }
$thefieldlikevalue = array(); $thefieldlikevalue = array();
foreach ($tblfields as $tblfield) { foreach ($tblfields as $tblfield) {
if ($tblfield['Charset'] != $charset_connection if (! isset($field) || strlen($field) == 0 || $tblfield == $field) {
&& $tblfield['Charset'] != 'NULL' $thefieldlikevalue[] = PMA_backquote($tblfield)
&& $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']
. ' ' . $like_or_regex . ' ' . ' ' . $like_or_regex . ' '
. $prefix . "'" . $automatic_wildcard
. "'"
. $automatic_wildcard
. $search_word . $search_word
. $automatic_wildcard . "'" . $automatic_wildcard . "'";
. $suffix;
} }
} // end for } // end for

View File

@@ -212,7 +212,7 @@ function PMA_DBI_get_tables($database, $link = null)
* @param string $table table * @param string $table table
* @param boolean|string $tbl_is_group $table is a table group * @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link * @param resource $link mysql link
* @param integer $limit_offset zero-based offset for the count * @param integer $limit_offset zero-based offset for the count
* @param boolean|integer $limit_count number of tables to return * @param boolean|integer $limit_count number of tables to return
* @return array list of tables in given db(s) * @return array list of tables in given db(s)
*/ */
@@ -786,7 +786,6 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null
* @uses PMA_DBI_query() * @uses PMA_DBI_query()
* @uses PMA_DBI_get_variable() * @uses PMA_DBI_get_variable()
* @uses $GLOBALS['collation_connection'] * @uses $GLOBALS['collation_connection']
* @uses $GLOBALS['charset_connection']
* @uses $GLOBALS['available_languages'] * @uses $GLOBALS['available_languages']
* @uses $GLOBALS['mysql_charset_map'] * @uses $GLOBALS['mysql_charset_map']
* @uses $GLOBALS['charset'] * @uses $GLOBALS['charset']

View File

@@ -1,7 +1,12 @@
<?php <?php
/* vim: set expandtab sw=4 ts=4 sts=4: */ /* 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$ * @version $Id$
*/ */
@@ -357,7 +362,7 @@ else {
list($charsets[$i]) = explode('_', $collations[$i]); list($charsets[$i]) = explode('_', $collations[$i]);
if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) { if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) {
$fields[$i] = ''; $fields[$i] = '';
$w[] = PMA_backquote(urldecode($names[$i])) . ' ' . $func_type; $w[] = PMA_backquote($names[$i]) . ' ' . $func_type;
} elseif (strncasecmp($types[$i], 'enum', 4) == 0) { } elseif (strncasecmp($types[$i], 'enum', 4) == 0) {
if (!empty($fields[$i])) { if (!empty($fields[$i])) {
@@ -380,20 +385,11 @@ else {
$parens_close = ''; $parens_close = '';
} }
$enum_where = '\'' . PMA_sqlAddslashes($fields[$i][0]) . '\''; $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++) { for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', '; $enum_where .= ', \'' . PMA_sqlAddslashes($fields[$i][$e]) . '\'';
$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);
} }
$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] != '') { } elseif ($fields[$i] != '') {
@@ -406,23 +402,12 @@ else {
$quot = ''; $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 %...% // LIKE %...%
if ($func_type == 'LIKE %...%') { if ($func_type == 'LIKE %...%') {
$func_type = 'LIKE'; $func_type = 'LIKE';
$fields[$i] = '%' . $fields[$i] . '%'; $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 if
} // end for } // end for
@@ -433,9 +418,10 @@ else {
} // end if } // end if
if ($orderField != '--nil--') { if ($orderField != '--nil--') {
$sql_query .= ' ORDER BY ' . PMA_backquote(urldecode($orderField)) . ' ' . $order; $sql_query .= ' ORDER BY ' . PMA_backquote($orderField) . ' ' . $order;
} // end if } // end if
include './sql.php';
require './sql.php';
} }
?> ?>