public addCheckConstraint ( $table, $definition, $name = '' ) | ||
$table | The table to which to add the check | |
$definition | The definition of the check | |
$name | (optional) The name to give the check, otherwise default name is assigned |
function addCheckConstraint($table, $definition, $name = '')
{
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
$this->fieldClean($table);
$this->fieldClean($name);
// @@ How the heck do you clean a definition???
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ADD ";
if ($name != '') {
$sql .= "CONSTRAINT \"{$name}\" ";
}
$sql .= "CHECK ({$definition})";
return $this->execute($sql);
}