bug 434608

This commit is contained in:
Marc Delisle
2001-06-27 14:17:59 +00:00
parent e66e54abcb
commit d4e5d0316f
6 changed files with 35 additions and 21 deletions

View File

@@ -303,7 +303,7 @@ function display_table ($dt_result, $is_simple = false) {
$primary = false;
if(!$is_simple && !empty($table) && !empty($db)) {
$result = mysql_query("SELECT COUNT(*) as total FROM $db.$table") or mysql_die();
$result = mysql_query("SELECT COUNT(*) as total FROM " .db_name($db).".$table") or mysql_die();
$row = mysql_fetch_array($result);
$total = $row["total"];
}
@@ -486,7 +486,7 @@ function get_table_def($db, $table, $crlf)
// modified by Lem9 to allow older MySQL versions to continue to work
if(MYSQL_MAJOR_VERSION == "3.23" && intval(MYSQL_MINOR_VERSION) > 20){
$result=mysql_query("show create table $db.$table");
$result=mysql_query("show create table " .db_name($db).".$table");
if ($result!=false && mysql_num_rows($result)>0){
$tmpres=mysql_fetch_array($result);
$tmp=$tmpres[1];
@@ -497,7 +497,7 @@ function get_table_def($db, $table, $crlf)
$schema_create .= "CREATE TABLE $table ($crlf";
$result = mysql_query("SHOW FIELDS FROM $db.$table") or mysql_die();
$result = mysql_query("SHOW FIELDS FROM " .db_name($db).".$table") or mysql_die();
while($row = mysql_fetch_array($result))
{
$schema_create .= " $row[Field] $row[Type]";
@@ -511,7 +511,7 @@ function get_table_def($db, $table, $crlf)
$schema_create .= ",$crlf";
}
$schema_create = ereg_replace(",".$crlf."$", "", $schema_create);
$result = mysql_query("SHOW KEYS FROM $db.$table") or mysql_die();
$result = mysql_query("SHOW KEYS FROM " .db_name($db).".$table") or mysql_die();
while($row = mysql_fetch_array($result))
{
$kname=$row['Key_name'];
@@ -567,7 +567,7 @@ function get_table_content ($db, $table, $handler){
// only php > 4.0.5 - staybyte - 27. June 2001
function get_table_content_fast($db, $table, $handler){
$result = mysql_query("SELECT * FROM $db.$table") or mysql_die();
$result = mysql_query("SELECT * FROM ".db_name($db).".$table") or mysql_die();
if ($result!=false){
for($j=0; $j<mysql_num_fields($result);$j++){
$field_set[$j]= mysql_field_name($result,$j);
@@ -611,7 +611,7 @@ function get_table_content_fast($db, $table, $handler){
function get_table_content_old($db, $table, $handler)
{
$result = mysql_query("SELECT * FROM $db.$table") or mysql_die();
$result = mysql_query("SELECT * FROM " . db_name($db) .".$table") or mysql_die();
$i = 0;
while($row = mysql_fetch_row($result))
{
@@ -667,7 +667,7 @@ function get_table_content_old($db, $table, $handler)
function count_records ($db,$table)
{
$result = mysql_query("select count(*) as num from $db.$table");
$result = mysql_query("select count(*) as num from ".db_name($db).".$table");
$num = mysql_result($result,0,"num");
echo $num;
}
@@ -678,7 +678,7 @@ function count_records ($db,$table)
// $handler must accept one parameter ($sql_insert);
function get_table_csv($db, $table, $sep, $handler)
{
$result = mysql_query("SELECT * FROM $db.$table") or mysql_die();
$result = mysql_query("SELECT * FROM ".db_name($db).".$table") or mysql_die();
$i = 0;
while($row = mysql_fetch_row($result))
{
@@ -907,6 +907,16 @@ function format_byte_down($value,$limes=6,$comma=0){
return array($returnvalue,$unit);
}
// to support special characters in db names: Lem9, 2001-06-27
function db_name ($db) {
if (MYSQL_MAJOR_VERSION >= "3.23"
&& intval(MYSQL_MINOR_VERSION) >= 6) {
return "`" . $db . "`";
}
else return $db;
}
include ("./defines.inc.php3");
} // $__LIB_INC__