|
@@ 4684-4700 (lines=17) @@
|
| 4681 |
|
* @param string $name (optional) The name to give the check, otherwise default name is assigned |
| 4682 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 4683 |
|
*/ |
| 4684 |
|
public function addCheckConstraint($table, $definition, $name = '') |
| 4685 |
|
{ |
| 4686 |
|
$f_schema = $this->_schema; |
| 4687 |
|
$this->fieldClean($f_schema); |
| 4688 |
|
$this->fieldClean($table); |
| 4689 |
|
$this->fieldClean($name); |
| 4690 |
|
// @@ How the heck do you clean a definition??? |
| 4691 |
|
|
| 4692 |
|
$sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ADD "; |
| 4693 |
|
if ($name != '') { |
| 4694 |
|
$sql .= "CONSTRAINT \"{$name}\" "; |
| 4695 |
|
} |
| 4696 |
|
|
| 4697 |
|
$sql .= "CHECK ({$definition})"; |
| 4698 |
|
|
| 4699 |
|
return $this->execute($sql); |
| 4700 |
|
} |
| 4701 |
|
|
| 4702 |
|
/** |
| 4703 |
|
* Drops a check constraint from a table |
|
@@ 5247-5262 (lines=16) @@
|
| 5244 |
|
* @param string $name (optional) The name to give the check, otherwise default name is assigned |
| 5245 |
|
* @return \PHPPgAdmin\Database\A 0 success |
| 5246 |
|
*/ |
| 5247 |
|
public function addDomainCheckConstraint($domain, $definition, $name = '') |
| 5248 |
|
{ |
| 5249 |
|
$f_schema = $this->_schema; |
| 5250 |
|
$this->fieldClean($f_schema); |
| 5251 |
|
$this->fieldClean($domain); |
| 5252 |
|
$this->fieldClean($name); |
| 5253 |
|
|
| 5254 |
|
$sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" ADD "; |
| 5255 |
|
if ($name != '') { |
| 5256 |
|
$sql .= "CONSTRAINT \"{$name}\" "; |
| 5257 |
|
} |
| 5258 |
|
|
| 5259 |
|
$sql .= "CHECK ({$definition})"; |
| 5260 |
|
|
| 5261 |
|
return $this->execute($sql); |
| 5262 |
|
} |
| 5263 |
|
|
| 5264 |
|
/** |
| 5265 |
|
* Drops a domain constraint |