private function _getTableComments($db, $table, $crlf, $do_relation = false, $do_mime = false, $aliases = array())
{
global $cfgRelation, $sql_backquotes;
$db_alias = $db;
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
$schema_create = '';
// Check if we can use Relations
list($res_rel, $have_rel) = PMA_getRelationsAndStatus($do_relation && !empty($cfgRelation['relation']), $db, $table);
if ($do_mime && $cfgRelation['mimework']) {
if (!($mime_map = PMA_getMIME($db, $table, true))) {
unset($mime_map);
}
}
if (isset($mime_map) && count($mime_map) > 0) {
$schema_create .= $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('MIME TYPES FOR TABLE') . ' ' . Util::backquote($table, $sql_backquotes) . ':');
foreach ($mime_map as $mime_field => $mime) {
$schema_create .= $this->_exportComment(' ' . Util::backquote($mime_field, $sql_backquotes)) . $this->_exportComment(' ' . Util::backquote($mime['mimetype'], $sql_backquotes));
}
$schema_create .= $this->_exportComment();
}
if ($have_rel) {
$schema_create .= $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('RELATIONS FOR TABLE') . ' ' . Util::backquote($table_alias, $sql_backquotes) . ':');
foreach ($res_rel as $rel_field => $rel) {
if ($rel_field != 'foreign_keys_data') {
$rel_field_alias = !empty($aliases[$db]['tables'][$table]['columns'][$rel_field]) ? $aliases[$db]['tables'][$table]['columns'][$rel_field] : $rel_field;
$schema_create .= $this->_exportComment(' ' . Util::backquote($rel_field_alias, $sql_backquotes)) . $this->_exportComment(' ' . Util::backquote($rel['foreign_table'], $sql_backquotes) . ' -> ' . Util::backquote($rel['foreign_field'], $sql_backquotes));
} else {
foreach ($rel as $one_key) {
foreach ($one_key['index_list'] as $index => $field) {
$rel_field_alias = !empty($aliases[$db]['tables'][$table]['columns'][$field]) ? $aliases[$db]['tables'][$table]['columns'][$field] : $field;
$schema_create .= $this->_exportComment(' ' . Util::backquote($rel_field_alias, $sql_backquotes)) . $this->_exportComment(' ' . Util::backquote($one_key['ref_table_name'], $sql_backquotes) . ' -> ' . Util::backquote($one_key['ref_index_list'][$index], $sql_backquotes));
}
}
}
}
$schema_create .= $this->_exportComment();
}
return $schema_create;
}