function updateSchema($schemaname, $comment, $name, $owner)
{
$this->fieldClean($schemaname);
$this->fieldClean($name);
$this->fieldClean($owner);
$status = $this->beginTransaction();
if ($status != 0) {
$this->rollbackTransaction();
return -1;
}
$status = $this->setComment('SCHEMA', $schemaname, '', $comment);
if ($status != 0) {
$this->rollbackTransaction();
return -1;
}
$schema_rs = $this->getSchemaByName($schemaname);
/* Only if the owner change */
if ($schema_rs->fields['ownername'] != $owner) {
$sql = "ALTER SCHEMA \"{$schemaname}\" OWNER TO \"{$owner}\"";
$status = $this->execute($sql);
if ($status != 0) {
$this->rollbackTransaction();
return -1;
}
}
// Only if the name has changed
if ($name != $schemaname) {
$sql = "ALTER SCHEMA \"{$schemaname}\" RENAME TO \"{$name}\"";
$status = $this->execute($sql);
if ($status != 0) {
$this->rollbackTransaction();
return -1;
}
}
return $this->endTransaction();
}