mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Fixed failure to output data in MySQL
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3148 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1be87672a2
commit
dffcc62a01
2 changed files with 69 additions and 81 deletions
|
@ -566,57 +566,41 @@ function get_table_content_postgresql($table, $handler)
|
|||
function get_table_content_mysql($table, $handler)
|
||||
{
|
||||
global $db;
|
||||
//
|
||||
// Grab the data from the table.
|
||||
//
|
||||
$result = $db->sql_query("SELECT * FROM $table");
|
||||
|
||||
if (!$result)
|
||||
// Grab the data from the table.
|
||||
if (!($result = $db->sql_query("SELECT * FROM $table")))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Failed in get_table_content (select *)", "", __LINE__, __FILE__, "SELECT * FROM $table");
|
||||
}
|
||||
|
||||
if($db->sql_numrows($result) > 0)
|
||||
{
|
||||
$schema_insert = "\n#\n# Table Data for $table\n#\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$schema_insert = "";
|
||||
}
|
||||
|
||||
$handler($schema_insert);
|
||||
|
||||
//
|
||||
// Loop through the resulting rows and build the sql statement.
|
||||
//
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$handler("\n#\n# Table Data for $table\n#\n");
|
||||
$field_names = array();
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$table_list = '(';
|
||||
$num_fields = $db->sql_numfields($result);
|
||||
//
|
||||
// Grab the list of field names.
|
||||
//
|
||||
$num_fields = $db->sql_numfields($result);
|
||||
$table_list = '(';
|
||||
for ($j = 0; $j < $num_fields; $j++)
|
||||
{
|
||||
$table_list .= $db->sql_fieldname($j, $result) . ', ';
|
||||
$field_names[$j] = $db->sql_fieldname($j, $result);
|
||||
$table_list .= (($j > 0) ? ', ' : '') . $field_names[$j];
|
||||
|
||||
}
|
||||
//
|
||||
// Get rid of the last comma
|
||||
//
|
||||
$table_list = ereg_replace(', $', '', $table_list);
|
||||
$table_list .= ')';
|
||||
//
|
||||
|
||||
do
|
||||
{
|
||||
// Start building the SQL statement.
|
||||
//
|
||||
$schema_insert = "INSERT INTO $table $table_list VALUES(";
|
||||
//
|
||||
|
||||
// Loop through the rows and fill in data for each column
|
||||
//
|
||||
for ($j = 0; $j < $num_fields; $j++)
|
||||
{
|
||||
if(!isset($row[$j]))
|
||||
$schema_insert .= ($j > 0) ? ', ' : '';
|
||||
|
||||
if(!isset($row[$field_names[$j]]))
|
||||
{
|
||||
//
|
||||
// If there is no data for the column set it to null.
|
||||
|
@ -624,28 +608,27 @@ function get_table_content_mysql($table, $handler)
|
|||
// sql file not to reimport if the last column was null in
|
||||
// any table. Should be fixed now :) JLH
|
||||
//
|
||||
$schema_insert .= ' NULL,';
|
||||
$schema_insert .= 'NULL';
|
||||
}
|
||||
elseif ($row[$j] != '')
|
||||
elseif ($row[$field_names[$j]] != '')
|
||||
{
|
||||
$schema_insert .= ' \'' . addslashes($row[$j]) . '\',';
|
||||
$schema_insert .= '\'' . addslashes($row[$field_names[$j]]) . '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
$schema_insert .= '\'\',';
|
||||
$schema_insert .= '\'\'';
|
||||
}
|
||||
}
|
||||
//
|
||||
// Get rid of the the last comma.
|
||||
//
|
||||
$schema_insert = ereg_replace(',$', '', $schema_insert);
|
||||
|
||||
$schema_insert .= ');';
|
||||
//
|
||||
|
||||
// Go ahead and send the insert statement to the handler function.
|
||||
//
|
||||
$handler(trim($schema_insert));
|
||||
|
||||
}
|
||||
while ($row = $db->sql_fetchrow($result));
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -833,15 +816,19 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
for($i = 0; $i < count($tables); $i++)
|
||||
{
|
||||
$table_name = $tables[$i];
|
||||
if(SQL_LAYER != 'mysql4')
|
||||
{
|
||||
$table_def_function = "get_table_def_" . SQL_LAYER;
|
||||
$table_content_function = "get_table_content_" . SQL_LAYER;
|
||||
}
|
||||
else
|
||||
|
||||
switch (SQL_LAYER)
|
||||
{
|
||||
case 'postgresql':
|
||||
$table_def_function = "get_table_def_postgresql";
|
||||
$table_content_function = "get_table_content_postgresql";
|
||||
break;
|
||||
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
$table_def_function = "get_table_def_mysql";
|
||||
$table_content_function = "get_table_content_mysql";
|
||||
break;
|
||||
}
|
||||
|
||||
if($backup_type != 'data')
|
||||
|
|
|
@ -122,8 +122,9 @@ h3 {font-size:12pt;color:blue}
|
|||
<li>Fixed empty username quoting owith MS-SQL</li>
|
||||
<li>Fixed BBCode url, magic url and img tags to allow most chars beyond domain names</li>
|
||||
<li>Prevent parsing of -ve size values in BBCode size tag</li>
|
||||
<li>Back ported HTML handler from 2.2, this may impact some boards which allow complex HTML</li>
|
||||
<li></li>
|
||||
<li>Back ported HTML handler from 2.2, this may impact some boards which allow complex HTML - existing parser remains but commented out</li>
|
||||
<li>Fixed parsing of word censors to not censor words within < and > tag delimiters</li>
|
||||
<li>Fixed database utilities failing to backup data with MySQL</li>
|
||||
<li></li>
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue