Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-03-06 14:14:10 +01:00
commit a609b4ccb7
4 changed files with 59 additions and 0 deletions

View File

@ -1572,5 +1572,25 @@ class PMA_Table
}
return true;
}
/**
* Get all column names which are MySQL reserved words
*
* @return array
* @access public
*/
public function getReservedColumnNames()
{
$columns = $this->getColumns($backquoted = false);
$return = array();
foreach ($columns as $column) {
$temp = explode('.', $column);
$column_name = $temp[2];
if (PMA_SQP_isKeyWord($column_name)) {
$return[] = $column_name;
}
}
return $return;
}
}
?>

View File

@ -2890,4 +2890,16 @@ function PMA_SQP_formatNone($arr)
return $formatted_sql;
} // end of the "PMA_SQP_formatNone()" function
/**
* Checks whether a given name is MySQL reserved word
*
* @param string $column The word to be checked
*
* @return boolean whether true or false
*/
function PMA_SQP_isKeyWord($column) {
global $PMA_SQPdata_forbidden_word;
return in_array(strtoupper($column), $PMA_SQPdata_forbidden_word);
}
?>

14
sql.php
View File

@ -1203,6 +1203,20 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
echo '</fieldset>' . "\n";
}
// Check column names for MySQL reserved words
$pma_table = new PMA_Table($table, $db);
$columns = $pma_table->getReservedColumnNames();
if (! empty($columns)) {
foreach ($columns as $column) {
$msg = PMA_message::notice(
__('The column name \'%s\' is a MySQL reserved keyword.')
);
$msg->addParam($column);
$msg->display();
}
}
// Displays the results in a table
if (empty($disp_mode)) {
// see the "PMA_setDisplayMode()" function in

View File

@ -133,6 +133,19 @@ $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
$url_params['goto'] = 'tbl_structure.php';
$url_params['back'] = 'tbl_structure.php';
// Check column names for MySQL reserved words
$pma_table = new PMA_Table($table, $db);
$columns = $pma_table->getReservedColumnNames();
if (! empty($columns)) {
foreach ($columns as $column) {
$msg = PMA_message::notice(
__('The column name \'%s\' is a MySQL reserved keyword.')
);
$msg->addParam($column);
$response->addHTML($msg);
}
}
/**
* Prepares the table structure display
*/