", htmlspecialchars($editor->getSql()));
if ($result)
print
'
1
'
.'
'.__('The command executed successfully').'.
'
.'
'.$formatted_query.'
'
.'
';
else
print
'0
'
.'
'.__('Error occurred while executing the query').':
'
.'
'.$formatted_query.'
'
.'
'.htmlspecialchars($db->getError()).'
'
.'
';
}
else
displayCreateTableForm($db);
}
function displayCreateTableForm(&$db) {
$rows = array();
include(BASE_PATH . '/lib/html.php');
$engines = html::arrayToOptions($db->getEngines(), '', true);
$charsets = html::arrayToOptions($db->getCharsets(), '', true);
$collations = html::arrayToOptions($db->getCollations(), '', true);
$comment = '';
$replace = array(
'ID' => v($_REQUEST["id"]) ? htmlspecialchars($_REQUEST["id"]) : '',
'MESSAGE' => '',
'ROWINFO' => json_encode($rows),
'ALTER_TABLE' => 'false',
'TABLE_NAME' => '',
'ENGINE' => $engines,
'CHARSET' => $charsets,
'COLLATION' => $collations,
'COMMENT' => htmlspecialchars($comment)
);
echo view('editable', $replace);
}
function createDatabaseTable(&$db, $info, &$editor) {
$info = json_decode($info);
if (!is_object($info))
return false;
if (v($info->name))
$editor->setName($info->name);
if (v($info->fields))
$editor->setFields($info->fields);
if (v($info->props))
$editor->setProperties($info->props);
$sql = $editor->getCreateStatement();
if (!$db->query($sql))
return false;
return true;
}
?>