| @@ 77-93 (lines=17) @@ | ||
| 74 | * @param $name The new name for the sequence |
|
| 75 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 76 | */ |
|
| 77 | public function alterSequenceName($seqrs, $name) |
|
| 78 | { |
|
| 79 | /* vars are cleaned in _alterSequence */ |
|
| 80 | if (!empty($name) && ($seqrs->fields['seqname'] != $name)) { |
|
| 81 | $f_schema = $this->_schema; |
|
| 82 | $this->fieldClean($f_schema); |
|
| 83 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" RENAME TO \"{$name}\""; |
|
| 84 | $status = $this->execute($sql); |
|
| 85 | if ($status == 0) { |
|
| 86 | $seqrs->fields['seqname'] = $name; |
|
| 87 | } else { |
|
| 88 | return $status; |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||
| 92 | return 0; |
|
| 93 | } |
|
| 94 | ||
| 95 | // View functions |
|
| 96 | ||
| @@ 104-121 (lines=18) @@ | ||
| 101 | * @param $name The new view's name |
|
| 102 | * @return int|\PHPPgAdmin\Database\A -1 Failed |
|
| 103 | */ |
|
| 104 | public function alterViewName($vwrs, $name) |
|
| 105 | { |
|
| 106 | // Rename (only if name has changed) |
|
| 107 | /* $vwrs and $name are cleaned in _alterView */ |
|
| 108 | if (!empty($name) && ($name != $vwrs->fields['relname'])) { |
|
| 109 | $f_schema = $this->_schema; |
|
| 110 | $this->fieldClean($f_schema); |
|
| 111 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" RENAME TO \"{$name}\""; |
|
| 112 | $status = $this->execute($sql); |
|
| 113 | if ($status == 0) { |
|
| 114 | $vwrs->fields['relname'] = $name; |
|
| 115 | } else { |
|
| 116 | return $status; |
|
| 117 | } |
|
| 118 | } |
|
| 119 | ||
| 120 | return 0; |
|
| 121 | } |
|
| 122 | ||
| 123 | // Trigger functions |
|
| 124 | ||
| @@ 2748-2766 (lines=19) @@ | ||
| 2745 | * @param $name The new table's name |
|
| 2746 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 2747 | */ |
|
| 2748 | public function alterTableName($tblrs, $name = null) |
|
| 2749 | { |
|
| 2750 | /* vars cleaned in _alterTable */ |
|
| 2751 | // Rename (only if name has changed) |
|
| 2752 | if (!empty($name) && ($name != $tblrs->fields['relname'])) { |
|
| 2753 | $f_schema = $this->_schema; |
|
| 2754 | $this->fieldClean($f_schema); |
|
| 2755 | ||
| 2756 | $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" RENAME TO \"{$name}\""; |
|
| 2757 | $status = $this->execute($sql); |
|
| 2758 | if ($status == 0) { |
|
| 2759 | $tblrs->fields['relname'] = $name; |
|
| 2760 | } else { |
|
| 2761 | return $status; |
|
| 2762 | } |
|
| 2763 | } |
|
| 2764 | ||
| 2765 | return 0; |
|
| 2766 | } |
|
| 2767 | ||
| 2768 | // Row functions |
|
| 2769 | ||
| @@ 4007-4023 (lines=17) @@ | ||
| 4004 | * @param $name The new name for the sequence |
|
| 4005 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 4006 | */ |
|
| 4007 | public function alterSequenceName($seqrs, $name) |
|
| 4008 | { |
|
| 4009 | /* vars are cleaned in _alterSequence */ |
|
| 4010 | if (!empty($name) && ($seqrs->fields['seqname'] != $name)) { |
|
| 4011 | $f_schema = $this->_schema; |
|
| 4012 | $this->fieldClean($f_schema); |
|
| 4013 | $sql = "ALTER SEQUENCE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" RENAME TO \"{$name}\""; |
|
| 4014 | $status = $this->execute($sql); |
|
| 4015 | if ($status == 0) { |
|
| 4016 | $seqrs->fields['seqname'] = $name; |
|
| 4017 | } else { |
|
| 4018 | return $status; |
|
| 4019 | } |
|
| 4020 | } |
|
| 4021 | ||
| 4022 | return 0; |
|
| 4023 | } |
|
| 4024 | ||
| 4025 | /** |
|
| 4026 | * Alter a sequence's schema |
|
| @@ 4305-4322 (lines=18) @@ | ||
| 4302 | * @param $name The new view's name |
|
| 4303 | * @return int|\PHPPgAdmin\Database\A 0 success |
|
| 4304 | */ |
|
| 4305 | public function alterViewName($vwrs, $name) |
|
| 4306 | { |
|
| 4307 | // Rename (only if name has changed) |
|
| 4308 | /* $vwrs and $name are cleaned in _alterView */ |
|
| 4309 | if (!empty($name) && ($name != $vwrs->fields['relname'])) { |
|
| 4310 | $f_schema = $this->_schema; |
|
| 4311 | $this->fieldClean($f_schema); |
|
| 4312 | $sql = "ALTER VIEW \"{$f_schema}\".\"{$vwrs->fields['relname']}\" RENAME TO \"{$name}\""; |
|
| 4313 | $status = $this->execute($sql); |
|
| 4314 | if ($status == 0) { |
|
| 4315 | $vwrs->fields['relname'] = $name; |
|
| 4316 | } else { |
|
| 4317 | return $status; |
|
| 4318 | } |
|
| 4319 | } |
|
| 4320 | ||
| 4321 | return 0; |
|
| 4322 | } |
|
| 4323 | ||
| 4324 | /** |
|
| 4325 | * Alter a view's schema |
|