@@ 268-283 (lines=16) @@ | ||
265 | * |
|
266 | * @return int 0 if operation was successful |
|
267 | */ |
|
268 | public function addDomainCheckConstraint($domain, $definition, $name = '') |
|
269 | { |
|
270 | $f_schema = $this->_schema; |
|
271 | $this->fieldClean($f_schema); |
|
272 | $this->fieldClean($domain); |
|
273 | $this->fieldClean($name); |
|
274 | ||
275 | $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" ADD "; |
|
276 | if ($name != '') { |
|
277 | $sql .= "CONSTRAINT \"{$name}\" "; |
|
278 | } |
|
279 | ||
280 | $sql .= "CHECK ({$definition})"; |
|
281 | ||
282 | return $this->execute($sql); |
|
283 | } |
|
284 | ||
285 | /** |
|
286 | * Drops a domain constraint. |
@@ 340-356 (lines=17) @@ | ||
337 | * |
|
338 | * @return int 0 if operation was successful |
|
339 | */ |
|
340 | public function addCheckConstraint($table, $definition, $name = '') |
|
341 | { |
|
342 | $f_schema = $this->_schema; |
|
343 | $this->fieldClean($f_schema); |
|
344 | $this->fieldClean($table); |
|
345 | $this->fieldClean($name); |
|
346 | // @@ How the heck do you clean a definition??? |
|
347 | ||
348 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ADD "; |
|
349 | if ($name != '') { |
|
350 | $sql .= "CONSTRAINT \"{$name}\" "; |
|
351 | } |
|
352 | ||
353 | $sql .= "CHECK ({$definition})"; |
|
354 | ||
355 | return $this->execute($sql); |
|
356 | } |
|
357 | ||
358 | /** |
|
359 | * Drops a check constraint from a table. |