function createView($viewname, $definition, $replace, $comment)
{
$status = $this->beginTransaction();
if ($status != 0) {
return -1;
}
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($viewname);
// Note: $definition not cleaned
$sql = "CREATE ";
if ($replace) {
$sql .= "OR REPLACE ";
}
$sql .= "VIEW \"{$f_schema}\".\"{$viewname}\" AS {$definition}";
$status = $this->execute($sql);
if ($status) {
$this->rollbackTransaction();
return -1;
}
if ($comment != '') {
$status = $this->setComment('VIEW', $viewname, '', $comment);
if ($status) {
$this->rollbackTransaction();
return -1;
}
}
return $this->endTransaction();
}