function setComment($obj_type, $obj_name, $table, $comment, $basetype = NULL)
{
$sql = "COMMENT ON {$obj_type} ";
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->clean($comment);
// Passing in an already cleaned comment will lead to double escaped data
// So, while counter-intuitive, it is important to not clean comments before
// calling setComment. We will clean it here instead.
/*
$this->fieldClean($table);
$this->fieldClean($obj_name);
*/
switch ($obj_type) {
case 'TABLE':
$sql .= "\"{$f_schema}\".\"{$table}\" IS ";
break;
case 'COLUMN':
$sql .= "\"{$f_schema}\".\"{$table}\".\"{$obj_name}\" IS ";
break;
case 'SEQUENCE':
case 'VIEW':
case 'TEXT SEARCH CONFIGURATION':
case 'TEXT SEARCH DICTIONARY':
case 'TEXT SEARCH TEMPLATE':
case 'TEXT SEARCH PARSER':
case 'TYPE':
$sql .= "\"{$f_schema}\".";
case 'DATABASE':
case 'ROLE':
case 'SCHEMA':
case 'TABLESPACE':
$sql .= "\"{$obj_name}\" IS ";
break;
case 'FUNCTION':
$sql .= "\"{$f_schema}\".{$obj_name} IS ";
break;
case 'AGGREGATE':
$sql .= "\"{$f_schema}\".\"{$obj_name}\" (\"{$basetype}\") IS ";
break;
default:
// Unknown object type
return -1;
}
if ($comment != '') {
$sql .= "'{$comment}';";
} else {
$sql .= 'NULL;';
}
return $this->execute($sql);
}