Generate valid PHP code even when table/database name contains PHP markup
Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
c6cfb58834
commit
34a1cebf76
@ -82,6 +82,18 @@ class ExportPhparray extends ExportPlugin
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes end of comment from a string
|
||||
*
|
||||
* @param string $string String to replace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function commentString($string)
|
||||
{
|
||||
return strtr($string, '*/', '-');
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs export header
|
||||
*
|
||||
@ -119,9 +131,9 @@ class ExportPhparray extends ExportPlugin
|
||||
public function exportDBHeader ($db)
|
||||
{
|
||||
PMA_exportOutputHandler(
|
||||
'//' . $GLOBALS['crlf']
|
||||
. '// Database ' . PMA_Util::backquote($db)
|
||||
. $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']
|
||||
'/**' . $GLOBALS['crlf']
|
||||
. ' * Database ' . $this->commentString(PMA_Util::backquote($db))
|
||||
. $GLOBALS['crlf'] . ' */' . $GLOBALS['crlf']
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@ -192,11 +204,11 @@ class ExportPhparray extends ExportPlugin
|
||||
$buffer = '';
|
||||
$record_cnt = 0;
|
||||
// Output table name as comment
|
||||
$buffer .= $crlf . '// '
|
||||
. PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table) . $crlf;
|
||||
$buffer .= $crlf . '/* '
|
||||
. $this->commentString(PMA_Util::backquote($db)) . '.'
|
||||
. $this->commentString(PMA_Util::backquote($table)) . ' */' . $crlf;
|
||||
$buffer .= '$' . $tablefixed . ' = array(';
|
||||
|
||||
|
||||
while ($record = PMA_DBI_fetch_row($result)) {
|
||||
$record_cnt++;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user