fixed bug #1469109 PMA_backquote() issues

This commit is contained in:
Sebastian Mendel
2006-04-12 08:47:44 +00:00
parent 3787870356
commit fefedf57f5
2 changed files with 26 additions and 19 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2006-04-11 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries\common.lib.php:
fixed bug #1469109 PMA_backquote() issues
2006-04-11 Marc Delisle <lem9@users.sourceforge.net> 2006-04-11 Marc Delisle <lem9@users.sourceforge.net>
* Documentation.html: clarification about config.default.php * Documentation.html: clarification about config.default.php

View File

@@ -1258,35 +1258,38 @@ if (!defined('PMA_MINIMUM_COMMON')) {
/** /**
* Adds backquotes on both sides of a database, table or field name. * Adds backquotes on both sides of a database, table or field name.
* Since MySQL 3.23.6 this allows to use non-alphanumeric characters in * and escapes backquotes inside the name with another backquote
* these names.
* *
* @param mixed the database, table or field name to "backquote" or * <code>
* array of it * echo PMA_backquote('owner`s db'); // `owner``s db`
* @param boolean a flag to bypass this function (used by dump * </code>
* functions)
* *
* @param mixed $a_name the database, table or field name to "backquote"
* or array of it
* @param boolean $do_it a flag to bypass this function (used by dump
* functions)
* @return mixed the "backquoted" database, table or field name if the * @return mixed the "backquoted" database, table or field name if the
* current MySQL release is >= 3.23.6, the original one * current MySQL release is >= 3.23.6, the original one
* else * else
*
* @access public * @access public
*/ */
function PMA_backquote($a_name, $do_it = true) function PMA_backquote($a_name, $do_it = true)
{ {
// '0' is also empty for php :-( if (! $do_it) {
if ($do_it return $a_name;
&& isset($a_name) && !empty($a_name) && $a_name != '*') { }
if (is_array($a_name)) { if (is_array($a_name)) {
$result = array(); $result = array();
foreach ($a_name as $key => $val) { foreach ($a_name as $key => $val) {
$result[$key] = '`' . $val . '`'; $result[$key] = PMA_backquote($val);
} }
return $result; return $result;
} else { }
return '`' . $a_name . '`';
} // '0' is also empty for php :-(
if (strlen($a_name) && $a_name != '*') {
return '`' . str_replace('`', '``', $a_name) . '`';
} else { } else {
return $a_name; return $a_name;
} }