| @@ 2876-2888 (lines=13) @@ | ||
| 2873 | * |
|
| 2874 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 2875 | */ |
|
| 2876 | public function dropTable($table, $cascade) |
|
| 2877 | { |
|
| 2878 | $f_schema = $this->_schema; |
|
| 2879 | $this->fieldClean($f_schema); |
|
| 2880 | $this->fieldClean($table); |
|
| 2881 | ||
| 2882 | $sql = "DROP TABLE \"{$f_schema}\".\"{$table}\""; |
|
| 2883 | if ($cascade) { |
|
| 2884 | $sql .= ' CASCADE'; |
|
| 2885 | } |
|
| 2886 | ||
| 2887 | return $this->execute($sql); |
|
| 2888 | } |
|
| 2889 | ||
| 2890 | /** |
|
| 2891 | * Add a new column to a table. |
|
| @@ 3140-3150 (lines=11) @@ | ||
| 3137 | * |
|
| 3138 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 3139 | */ |
|
| 3140 | public function setColumnDefault($table, $column, $default) |
|
| 3141 | { |
|
| 3142 | $f_schema = $this->_schema; |
|
| 3143 | $this->fieldClean($f_schema); |
|
| 3144 | $this->fieldClean($table); |
|
| 3145 | $this->fieldClean($column); |
|
| 3146 | ||
| 3147 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ALTER COLUMN \"{$column}\" SET DEFAULT {$default}"; |
|
| 3148 | ||
| 3149 | return $this->execute($sql); |
|
| 3150 | } |
|
| 3151 | ||
| 3152 | /** |
|
| 3153 | * Sets whether or not a column can contain NULLs. |
|
| @@ 3182-3195 (lines=14) @@ | ||
| 3179 | * |
|
| 3180 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 3181 | */ |
|
| 3182 | public function dropColumn($table, $column, $cascade) |
|
| 3183 | { |
|
| 3184 | $f_schema = $this->_schema; |
|
| 3185 | $this->fieldClean($f_schema); |
|
| 3186 | $this->fieldClean($table); |
|
| 3187 | $this->fieldClean($column); |
|
| 3188 | ||
| 3189 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" DROP COLUMN \"{$column}\""; |
|
| 3190 | if ($cascade) { |
|
| 3191 | $sql .= ' CASCADE'; |
|
| 3192 | } |
|
| 3193 | ||
| 3194 | return $this->execute($sql); |
|
| 3195 | } |
|
| 3196 | ||
| 3197 | /** |
|
| 3198 | * Drops default value of a column. |
|
| @@ 3205-3215 (lines=11) @@ | ||
| 3202 | * |
|
| 3203 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 3204 | */ |
|
| 3205 | public function dropColumnDefault($table, $column) |
|
| 3206 | { |
|
| 3207 | $f_schema = $this->_schema; |
|
| 3208 | $this->fieldClean($f_schema); |
|
| 3209 | $this->fieldClean($table); |
|
| 3210 | $this->fieldClean($column); |
|
| 3211 | ||
| 3212 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ALTER COLUMN \"{$column}\" DROP DEFAULT"; |
|
| 3213 | ||
| 3214 | return $this->execute($sql); |
|
| 3215 | } |
|
| 3216 | ||
| 3217 | /** |
|
| 3218 | * Sets up the data object for a dump. eg. Starts the appropriate |
|
| @@ 3726-3736 (lines=11) @@ | ||
| 3723 | * |
|
| 3724 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 3725 | */ |
|
| 3726 | public function restartSequence($sequence) |
|
| 3727 | { |
|
| 3728 | $f_schema = $this->_schema; |
|
| 3729 | $this->fieldClean($f_schema); |
|
| 3730 | $this->fieldClean($sequence); |
|
| 3731 | ||
| 3732 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$sequence}\" RESTART;"; |
|
| 3733 | ||
| 3734 | return $this->execute($sql); |
|
| 3735 | } |
|
| 3736 | ||
| 3737 | /** |
|
| 3738 | * Resets a given sequence to min value of sequence. |
|
| 3739 | * |
|
| @@ 4142-4154 (lines=13) @@ | ||
| 4139 | * |
|
| 4140 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 4141 | */ |
|
| 4142 | public function dropSequence($sequence, $cascade) |
|
| 4143 | { |
|
| 4144 | $f_schema = $this->_schema; |
|
| 4145 | $this->fieldClean($f_schema); |
|
| 4146 | $this->fieldClean($sequence); |
|
| 4147 | ||
| 4148 | $sql = "DROP SEQUENCE \"{$f_schema}\".\"{$sequence}\""; |
|
| 4149 | if ($cascade) { |
|
| 4150 | $sql .= ' CASCADE'; |
|
| 4151 | } |
|
| 4152 | ||
| 4153 | return $this->execute($sql); |
|
| 4154 | } |
|
| 4155 | ||
| 4156 | /** |
|
| 4157 | * Returns a list of all views in the database. |
|
| @@ 4454-4466 (lines=13) @@ | ||
| 4451 | * |
|
| 4452 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 4453 | */ |
|
| 4454 | public function dropView($viewname, $cascade) |
|
| 4455 | { |
|
| 4456 | $f_schema = $this->_schema; |
|
| 4457 | $this->fieldClean($f_schema); |
|
| 4458 | $this->fieldClean($viewname); |
|
| 4459 | ||
| 4460 | $sql = "DROP VIEW \"{$f_schema}\".\"{$viewname}\""; |
|
| 4461 | if ($cascade) { |
|
| 4462 | $sql .= ' CASCADE'; |
|
| 4463 | } |
|
| 4464 | ||
| 4465 | return $this->execute($sql); |
|
| 4466 | } |
|
| 4467 | ||
| 4468 | // Domain functions |
|
| 4469 | ||
| @@ 4559-4571 (lines=13) @@ | ||
| 4556 | * |
|
| 4557 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 4558 | */ |
|
| 4559 | public function dropIndex($index, $cascade) |
|
| 4560 | { |
|
| 4561 | $f_schema = $this->_schema; |
|
| 4562 | $this->fieldClean($f_schema); |
|
| 4563 | $this->fieldClean($index); |
|
| 4564 | ||
| 4565 | $sql = "DROP INDEX \"{$f_schema}\".\"{$index}\""; |
|
| 4566 | if ($cascade) { |
|
| 4567 | $sql .= ' CASCADE'; |
|
| 4568 | } |
|
| 4569 | ||
| 4570 | return $this->execute($sql); |
|
| 4571 | } |
|
| 4572 | ||
| 4573 | /** |
|
| 4574 | * Rebuild indexes. |
|
| @@ 4959-4972 (lines=14) @@ | ||
| 4956 | * |
|
| 4957 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 4958 | */ |
|
| 4959 | public function dropConstraint($constraint, $relation, $type, $cascade) |
|
| 4960 | { |
|
| 4961 | $f_schema = $this->_schema; |
|
| 4962 | $this->fieldClean($f_schema); |
|
| 4963 | $this->fieldClean($constraint); |
|
| 4964 | $this->fieldClean($relation); |
|
| 4965 | ||
| 4966 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$relation}\" DROP CONSTRAINT \"{$constraint}\""; |
|
| 4967 | if ($cascade) { |
|
| 4968 | $sql .= ' CASCADE'; |
|
| 4969 | } |
|
| 4970 | ||
| 4971 | return $this->execute($sql); |
|
| 4972 | } |
|
| 4973 | ||
| 4974 | /** |
|
| 4975 | * A function for getting all columns linked by foreign keys given a group of tables. |
|
| @@ 5343-5355 (lines=13) @@ | ||
| 5340 | * |
|
| 5341 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 5342 | */ |
|
| 5343 | public function dropDomain($domain, $cascade) |
|
| 5344 | { |
|
| 5345 | $f_schema = $this->_schema; |
|
| 5346 | $this->fieldClean($f_schema); |
|
| 5347 | $this->fieldClean($domain); |
|
| 5348 | ||
| 5349 | $sql = "DROP DOMAIN \"{$f_schema}\".\"{$domain}\""; |
|
| 5350 | if ($cascade) { |
|
| 5351 | $sql .= ' CASCADE'; |
|
| 5352 | } |
|
| 5353 | ||
| 5354 | return $this->execute($sql); |
|
| 5355 | } |
|
| 5356 | ||
| 5357 | /** |
|
| 5358 | * Adds a check constraint to a domain. |
|
| @@ 5392-5405 (lines=14) @@ | ||
| 5389 | * |
|
| 5390 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 5391 | */ |
|
| 5392 | public function dropDomainConstraint($domain, $constraint, $cascade) |
|
| 5393 | { |
|
| 5394 | $f_schema = $this->_schema; |
|
| 5395 | $this->fieldClean($f_schema); |
|
| 5396 | $this->fieldClean($domain); |
|
| 5397 | $this->fieldClean($constraint); |
|
| 5398 | ||
| 5399 | $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" DROP CONSTRAINT \"{$constraint}\""; |
|
| 5400 | if ($cascade) { |
|
| 5401 | $sql .= ' CASCADE'; |
|
| 5402 | } |
|
| 5403 | ||
| 5404 | return $this->execute($sql); |
|
| 5405 | } |
|
| 5406 | ||
| 5407 | // Rule functions |
|
| 5408 | ||
| @@ 5882-5894 (lines=13) @@ | ||
| 5879 | * |
|
| 5880 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 5881 | */ |
|
| 5882 | public function dropType($typname, $cascade) |
|
| 5883 | { |
|
| 5884 | $f_schema = $this->_schema; |
|
| 5885 | $this->fieldClean($f_schema); |
|
| 5886 | $this->fieldClean($typname); |
|
| 5887 | ||
| 5888 | $sql = "DROP TYPE \"{$f_schema}\".\"{$typname}\""; |
|
| 5889 | if ($cascade) { |
|
| 5890 | $sql .= ' CASCADE'; |
|
| 5891 | } |
|
| 5892 | ||
| 5893 | return $this->execute($sql); |
|
| 5894 | } |
|
| 5895 | ||
| 5896 | /** |
|
| 5897 | * Creates a new enum type in the database. |
|
| @@ 6243-6256 (lines=14) @@ | ||
| 6240 | * |
|
| 6241 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 6242 | */ |
|
| 6243 | public function dropRule($rule, $relation, $cascade) |
|
| 6244 | { |
|
| 6245 | $f_schema = $this->_schema; |
|
| 6246 | $this->fieldClean($f_schema); |
|
| 6247 | $this->fieldClean($rule); |
|
| 6248 | $this->fieldClean($relation); |
|
| 6249 | ||
| 6250 | $sql = "DROP RULE \"{$rule}\" ON \"{$f_schema}\".\"{$relation}\""; |
|
| 6251 | if ($cascade) { |
|
| 6252 | $sql .= ' CASCADE'; |
|
| 6253 | } |
|
| 6254 | ||
| 6255 | return $this->execute($sql); |
|
| 6256 | } |
|
| 6257 | ||
| 6258 | /** |
|
| 6259 | * Grabs a single trigger. |
|
| @@ 6526-6539 (lines=14) @@ | ||
| 6523 | * |
|
| 6524 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 6525 | */ |
|
| 6526 | public function dropTrigger($tgname, $table, $cascade) |
|
| 6527 | { |
|
| 6528 | $f_schema = $this->_schema; |
|
| 6529 | $this->fieldClean($f_schema); |
|
| 6530 | $this->fieldClean($tgname); |
|
| 6531 | $this->fieldClean($table); |
|
| 6532 | ||
| 6533 | $sql = "DROP TRIGGER \"{$tgname}\" ON \"{$f_schema}\".\"{$table}\""; |
|
| 6534 | if ($cascade) { |
|
| 6535 | $sql .= ' CASCADE'; |
|
| 6536 | } |
|
| 6537 | ||
| 6538 | return $this->execute($sql); |
|
| 6539 | } |
|
| 6540 | ||
| 6541 | /** |
|
| 6542 | * Enables a trigger. |
|
| @@ 6549-6559 (lines=11) @@ | ||
| 6546 | * |
|
| 6547 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 6548 | */ |
|
| 6549 | public function enableTrigger($tgname, $table) |
|
| 6550 | { |
|
| 6551 | $f_schema = $this->_schema; |
|
| 6552 | $this->fieldClean($f_schema); |
|
| 6553 | $this->fieldClean($tgname); |
|
| 6554 | $this->fieldClean($table); |
|
| 6555 | ||
| 6556 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ENABLE TRIGGER \"{$tgname}\""; |
|
| 6557 | ||
| 6558 | return $this->execute($sql); |
|
| 6559 | } |
|
| 6560 | ||
| 6561 | /** |
|
| 6562 | * Disables a trigger. |
|
| @@ 6569-6579 (lines=11) @@ | ||
| 6566 | * |
|
| 6567 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 6568 | */ |
|
| 6569 | public function disableTrigger($tgname, $table) |
|
| 6570 | { |
|
| 6571 | $f_schema = $this->_schema; |
|
| 6572 | $this->fieldClean($f_schema); |
|
| 6573 | $this->fieldClean($tgname); |
|
| 6574 | $this->fieldClean($table); |
|
| 6575 | ||
| 6576 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" DISABLE TRIGGER \"{$tgname}\""; |
|
| 6577 | ||
| 6578 | return $this->execute($sql); |
|
| 6579 | } |
|
| 6580 | ||
| 6581 | /** |
|
| 6582 | * Returns a list of all operators in the database. |
|
| @@ 6937-6949 (lines=13) @@ | ||
| 6934 | * |
|
| 6935 | * @return \PHPPgAdmin\Database\A 0 on success |
|
| 6936 | */ |
|
| 6937 | public function dropFtsConfiguration($ftscfg, $cascade) |
|
| 6938 | { |
|
| 6939 | $f_schema = $this->_schema; |
|
| 6940 | $this->fieldClean($f_schema); |
|
| 6941 | $this->fieldClean($ftscfg); |
|
| 6942 | ||
| 6943 | $sql = "DROP TEXT SEARCH CONFIGURATION \"{$f_schema}\".\"{$ftscfg}\""; |
|
| 6944 | if ($cascade) { |
|
| 6945 | $sql .= ' CASCADE'; |
|
| 6946 | } |
|
| 6947 | ||
| 6948 | return $this->execute($sql); |
|
| 6949 | } |
|
| 6950 | ||
| 6951 | /** |
|
| 6952 | * Drops FTS dictionary. |
|
| @@ 6961-6974 (lines=14) @@ | ||
| 6958 | * |
|
| 6959 | * @todo Support of dictionary templates dropping |
|
| 6960 | */ |
|
| 6961 | public function dropFtsDictionary($ftsdict, $cascade) |
|
| 6962 | { |
|
| 6963 | $f_schema = $this->_schema; |
|
| 6964 | $this->fieldClean($f_schema); |
|
| 6965 | $this->fieldClean($ftsdict); |
|
| 6966 | ||
| 6967 | $sql = 'DROP TEXT SEARCH DICTIONARY'; |
|
| 6968 | $sql .= " \"{$f_schema}\".\"{$ftsdict}\""; |
|
| 6969 | if ($cascade) { |
|
| 6970 | $sql .= ' CASCADE'; |
|
| 6971 | } |
|
| 6972 | ||
| 6973 | return $this->execute($sql); |
|
| 6974 | } |
|
| 6975 | ||
| 6976 | /** |
|
| 6977 | * Alters FTS configuration. |
|
| @@ 7423-7436 (lines=14) @@ | ||
| 7420 | * |
|
| 7421 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 7422 | */ |
|
| 7423 | public function dropAggregate($aggrname, $aggrtype, $cascade) |
|
| 7424 | { |
|
| 7425 | $f_schema = $this->_schema; |
|
| 7426 | $this->fieldClean($f_schema); |
|
| 7427 | $this->fieldClean($aggrname); |
|
| 7428 | $this->fieldClean($aggrtype); |
|
| 7429 | ||
| 7430 | $sql = "DROP AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\")"; |
|
| 7431 | if ($cascade) { |
|
| 7432 | $sql .= ' CASCADE'; |
|
| 7433 | } |
|
| 7434 | ||
| 7435 | return $this->execute($sql); |
|
| 7436 | } |
|
| 7437 | ||
| 7438 | /** |
|
| 7439 | * Gets all information for an aggregate. |
|
| @@ 7579-7588 (lines=10) @@ | ||
| 7576 | * |
|
| 7577 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 7578 | */ |
|
| 7579 | public function changeAggregateOwner($aggrname, $aggrtype, $newaggrowner) |
|
| 7580 | { |
|
| 7581 | $f_schema = $this->_schema; |
|
| 7582 | $this->fieldClean($f_schema); |
|
| 7583 | $this->fieldClean($aggrname); |
|
| 7584 | $this->fieldClean($newaggrowner); |
|
| 7585 | $sql = "ALTER AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\") OWNER TO \"{$newaggrowner}\""; |
|
| 7586 | ||
| 7587 | return $this->execute($sql); |
|
| 7588 | } |
|
| 7589 | ||
| 7590 | /** |
|
| 7591 | * Changes the schema of an aggregate function. |
|
| @@ 7599-7608 (lines=10) @@ | ||
| 7596 | * |
|
| 7597 | * @return \PHPPgAdmin\Database\A 0 success |
|
| 7598 | */ |
|
| 7599 | public function changeAggregateSchema($aggrname, $aggrtype, $newaggrschema) |
|
| 7600 | { |
|
| 7601 | $f_schema = $this->_schema; |
|
| 7602 | $this->fieldClean($f_schema); |
|
| 7603 | $this->fieldClean($aggrname); |
|
| 7604 | $this->fieldClean($newaggrschema); |
|
| 7605 | $sql = "ALTER AGGREGATE \"{$f_schema}\".\"{$aggrname}\" (\"{$aggrtype}\") SET SCHEMA \"{$newaggrschema}\""; |
|
| 7606 | ||
| 7607 | return $this->execute($sql); |
|
| 7608 | } |
|
| 7609 | ||
| 7610 | /** |
|
| 7611 | * Renames an aggregate function. |
|
| @@ 8703-8716 (lines=14) @@ | ||
| 8700 | * |
|
| 8701 | * @return \PHPPgAdmin\Database\A |
|
| 8702 | */ |
|
| 8703 | public function analyzeDB($table = '') |
|
| 8704 | { |
|
| 8705 | if ($table != '') { |
|
| 8706 | $f_schema = $this->_schema; |
|
| 8707 | $this->fieldClean($f_schema); |
|
| 8708 | $this->fieldClean($table); |
|
| 8709 | ||
| 8710 | $sql = "ANALYZE \"{$f_schema}\".\"{$table}\""; |
|
| 8711 | } else { |
|
| 8712 | $sql = 'ANALYZE'; |
|
| 8713 | } |
|
| 8714 | ||
| 8715 | return $this->execute($sql); |
|
| 8716 | } |
|
| 8717 | ||
| 8718 | /** |
|
| 8719 | * Vacuums a database. |
|