function createDatabase($database, $encoding, $tablespace = '', $comment = '', $template = 'template1', $lc_collate = '', $lc_ctype = '')
{
$this->fieldClean($database);
$this->clean($encoding);
$this->fieldClean($tablespace);
$this->fieldClean($template);
$this->clean($lc_collate);
$this->clean($lc_ctype);
$sql = "CREATE DATABASE \"{$database}\" WITH TEMPLATE=\"{$template}\"";
if ($encoding != '') {
$sql .= " ENCODING='{$encoding}'";
}
if ($lc_collate != '') {
$sql .= " LC_COLLATE='{$lc_collate}'";
}
if ($lc_ctype != '') {
$sql .= " LC_CTYPE='{$lc_ctype}'";
}
if ($tablespace != '' && $this->hasTablespaces()) {
$sql .= " TABLESPACE \"{$tablespace}\"";
}
$status = $this->execute($sql);
if ($status != 0) {
return -1;
}
if ($comment != '' && $this->hasSharedComments()) {
$status = $this->setComment('DATABASE', $database, '', $comment);
if ($status != 0) {
return -2;
}
}
return 0;
}