| @@ 2697-2712 (lines=16) @@ | ||
| 2694 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 2695 | * @internal param \PHPPgAdmin\Database\The $name new table's owner |
|
| 2696 | */ |
|
| 2697 | public function alterTableOwner($tblrs, $owner = null) |
|
| 2698 | { |
|
| 2699 | /* vars cleaned in _alterTable */ |
|
| 2700 | if (!empty($owner) && ($tblrs->fields['relowner'] != $owner)) { |
|
| 2701 | $f_schema = $this->_schema; |
|
| 2702 | $this->fieldClean($f_schema); |
|
| 2703 | // If owner has been changed, then do the alteration. We are |
|
| 2704 | // careful to avoid this generally as changing owner is a |
|
| 2705 | // superuser only function. |
|
| 2706 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" OWNER TO \"{$owner}\""; |
|
| 2707 | ||
| 2708 | return $this->execute($sql); |
|
| 2709 | } |
|
| 2710 | ||
| 2711 | return 0; |
|
| 2712 | } |
|
| 2713 | ||
| 2714 | /** |
|
| 2715 | * Alter a table's tablespace |
|
| @@ 2723-2738 (lines=16) @@ | ||
| 2720 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 2721 | * @internal param \PHPPgAdmin\Database\The $name new table's tablespace |
|
| 2722 | */ |
|
| 2723 | public function alterTableTablespace($tblrs, $tablespace = null) |
|
| 2724 | { |
|
| 2725 | /* vars cleaned in _alterTable */ |
|
| 2726 | if (!empty($tablespace) && ($tblrs->fields['tablespace'] != $tablespace)) { |
|
| 2727 | $f_schema = $this->_schema; |
|
| 2728 | $this->fieldClean($f_schema); |
|
| 2729 | ||
| 2730 | // If tablespace has been changed, then do the alteration. We |
|
| 2731 | // don't want to do this unnecessarily. |
|
| 2732 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET TABLESPACE \"{$tablespace}\""; |
|
| 2733 | ||
| 2734 | return $this->execute($sql); |
|
| 2735 | } |
|
| 2736 | ||
| 2737 | return 0; |
|
| 2738 | } |
|
| 2739 | ||
| 2740 | /** |
|
| 2741 | * Alter a table's name |
|
| @@ 2779-2793 (lines=15) @@ | ||
| 2776 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 2777 | * @internal param \PHPPgAdmin\Database\The $name new table's schema |
|
| 2778 | */ |
|
| 2779 | public function alterTableSchema($tblrs, $schema = null) |
|
| 2780 | { |
|
| 2781 | /* vars cleaned in _alterTable */ |
|
| 2782 | if (!empty($schema) && ($tblrs->fields['nspname'] != $schema)) { |
|
| 2783 | $f_schema = $this->_schema; |
|
| 2784 | $this->fieldClean($f_schema); |
|
| 2785 | // If tablespace has been changed, then do the alteration. We |
|
| 2786 | // don't want to do this unnecessarily. |
|
| 2787 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET SCHEMA \"{$schema}\""; |
|
| 2788 | ||
| 2789 | return $this->execute($sql); |
|
| 2790 | } |
|
| 2791 | ||
| 2792 | return 0; |
|
| 2793 | } |
|
| 2794 | ||
| 2795 | /** |
|
| 2796 | * Empties a table in the database |
|
| @@ 3918-3933 (lines=16) @@ | ||
| 3915 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 3916 | * @internal param \PHPPgAdmin\Database\The $name new owner for the sequence |
|
| 3917 | */ |
|
| 3918 | public function alterSequenceOwner($seqrs, $owner) |
|
| 3919 | { |
|
| 3920 | // If owner has been changed, then do the alteration. We are |
|
| 3921 | // careful to avoid this generally as changing owner is a |
|
| 3922 | // superuser only function. |
|
| 3923 | /* vars are cleaned in _alterSequence */ |
|
| 3924 | if (!empty($owner) && ($seqrs->fields['seqowner'] != $owner)) { |
|
| 3925 | $f_schema = $this->_schema; |
|
| 3926 | $this->fieldClean($f_schema); |
|
| 3927 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" OWNER TO \"{$owner}\""; |
|
| 3928 | ||
| 3929 | return $this->execute($sql); |
|
| 3930 | } |
|
| 3931 | ||
| 3932 | return 0; |
|
| 3933 | } |
|
| 3934 | ||
| 3935 | /** |
|
| 3936 | * Alter a sequence's properties |
|
| @@ 4033-4045 (lines=13) @@ | ||
| 4030 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 4031 | * @internal param \PHPPgAdmin\Database\The $name new schema for the sequence |
|
| 4032 | */ |
|
| 4033 | public function alterSequenceSchema($seqrs, $schema) |
|
| 4034 | { |
|
| 4035 | /* vars are cleaned in _alterSequence */ |
|
| 4036 | if (!empty($schema) && ($seqrs->fields['nspname'] != $schema)) { |
|
| 4037 | $f_schema = $this->_schema; |
|
| 4038 | $this->fieldClean($f_schema); |
|
| 4039 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" SET SCHEMA {$schema}"; |
|
| 4040 | ||
| 4041 | return $this->execute($sql); |
|
| 4042 | } |
|
| 4043 | ||
| 4044 | return 0; |
|
| 4045 | } |
|
| 4046 | ||
| 4047 | /** |
|
| 4048 | * Drops a given sequence |
|
| @@ 4281-4296 (lines=16) @@ | ||
| 4278 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 4279 | * @internal param \PHPPgAdmin\Database\The $name new view's owner |
|
| 4280 | */ |
|
| 4281 | public function alterViewOwner($vwrs, $owner = null) |
|
| 4282 | { |
|
| 4283 | /* $vwrs and $owner are cleaned in _alterView */ |
|
| 4284 | if ((!empty($owner)) && ($vwrs->fields['relowner'] != $owner)) { |
|
| 4285 | $f_schema = $this->_schema; |
|
| 4286 | $this->fieldClean($f_schema); |
|
| 4287 | // If owner has been changed, then do the alteration. We are |
|
| 4288 | // careful to avoid this generally as changing owner is a |
|
| 4289 | // superuser only function. |
|
| 4290 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" OWNER TO \"{$owner}\""; |
|
| 4291 | ||
| 4292 | return $this->execute($sql); |
|
| 4293 | } |
|
| 4294 | ||
| 4295 | return 0; |
|
| 4296 | } |
|
| 4297 | ||
| 4298 | /** |
|
| 4299 | * Rename a view |
|
| @@ 4332-4346 (lines=15) @@ | ||
| 4329 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 4330 | * @internal param \PHPPgAdmin\Database\The $name new view's schema |
|
| 4331 | */ |
|
| 4332 | public function alterViewSchema($vwrs, $schema) |
|
| 4333 | { |
|
| 4334 | /* $vwrs and $schema are cleaned in _alterView */ |
|
| 4335 | if (!empty($schema) && ($vwrs->fields['nspname'] != $schema)) { |
|
| 4336 | $f_schema = $this->_schema; |
|
| 4337 | $this->fieldClean($f_schema); |
|
| 4338 | // If tablespace has been changed, then do the alteration. We |
|
| 4339 | // don't want to do this unnecessarily. |
|
| 4340 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" SET SCHEMA \"{$schema}\""; |
|
| 4341 | ||
| 4342 | return $this->execute($sql); |
|
| 4343 | } |
|
| 4344 | ||
| 4345 | return 0; |
|
| 4346 | } |
|
| 4347 | ||
| 4348 | /** |
|
| 4349 | * Drops a view. |
|
| @@ 346-361 (lines=16) @@ | ||
| 343 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 344 | * @internal param \PHPPgAdmin\Database\The $name new owner for the sequence |
|
| 345 | */ |
|
| 346 | public function alterSequenceOwner($seqrs, $owner) |
|
| 347 | { |
|
| 348 | // If owner has been changed, then do the alteration. We are |
|
| 349 | // careful to avoid this generally as changing owner is a |
|
| 350 | // superuser only function. |
|
| 351 | /* vars are cleaned in _alterSequence */ |
|
| 352 | if (!empty($owner) && ($seqrs->fields['seqowner'] != $owner)) { |
|
| 353 | $f_schema = $this->_schema; |
|
| 354 | $this->fieldClean($f_schema); |
|
| 355 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" OWNER TO \"{$owner}\""; |
|
| 356 | ||
| 357 | return $this->execute($sql); |
|
| 358 | } |
|
| 359 | ||
| 360 | return 0; |
|
| 361 | } |
|
| 362 | ||
| 363 | // Function functions |
|
| 364 | ||