| @@ 4791-4807 (lines=17) @@ | ||
| 4788 | * |
|
| 4789 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 4790 | */ |
|
| 4791 | public function addCheckConstraint($table, $definition, $name = '') |
|
| 4792 | { |
|
| 4793 | $f_schema = $this->_schema; |
|
| 4794 | $this->fieldClean($f_schema); |
|
| 4795 | $this->fieldClean($table); |
|
| 4796 | $this->fieldClean($name); |
|
| 4797 | // @@ How the heck do you clean a definition??? |
|
| 4798 | ||
| 4799 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ADD "; |
|
| 4800 | if ($name != '') { |
|
| 4801 | $sql .= "CONSTRAINT \"{$name}\" "; |
|
| 4802 | } |
|
| 4803 | ||
| 4804 | $sql .= "CHECK ({$definition})"; |
|
| 4805 | ||
| 4806 | return $this->execute($sql); |
|
| 4807 | } |
|
| 4808 | ||
| 4809 | /** |
|
| 4810 | * Drops a check constraint from a table. |
|
| @@ 5366-5381 (lines=16) @@ | ||
| 5363 | * |
|
| 5364 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 5365 | */ |
|
| 5366 | public function addDomainCheckConstraint($domain, $definition, $name = '') |
|
| 5367 | { |
|
| 5368 | $f_schema = $this->_schema; |
|
| 5369 | $this->fieldClean($f_schema); |
|
| 5370 | $this->fieldClean($domain); |
|
| 5371 | $this->fieldClean($name); |
|
| 5372 | ||
| 5373 | $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" ADD "; |
|
| 5374 | if ($name != '') { |
|
| 5375 | $sql .= "CONSTRAINT \"{$name}\" "; |
|
| 5376 | } |
|
| 5377 | ||
| 5378 | $sql .= "CHECK ({$definition})"; |
|
| 5379 | ||
| 5380 | return $this->execute($sql); |
|
| 5381 | } |
|
| 5382 | ||
| 5383 | /** |
|
| 5384 | * Drops a domain constraint. |
|