| @@ -34,19 +34,13 @@ | ||
| 34 | 34 | { |
| 35 | 35 | return $this->wpDatabase->prefix . self::USER_GROUP_TO_OBJECT_TABLE_NAME; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * @see dbDelta() | |
| 40 | - */ | |
| 41 | 38 | public function dbDelta(string $queries = '', bool $execute = true): array |
| 42 | 39 | { |
| 43 | 40 | return $this->wordpress->dbDelta($queries, $execute); |
| 44 | 41 | } |
| 45 | 42 | |
| 46 | - /** | |
| 47 | - * @see wpdb | |
| 48 | - */ | |
| 49 | 43 | public function getPrefix(): string |
| 50 | 44 | { |
| 51 | 45 | return $this->wpDatabase->prefix; |
| 52 | 46 | } |
| @@ -90,110 +84,98 @@ | ||
| 90 | 84 | { |
| 91 | 85 | return $this->wpDatabase->prefix . 'capabilities'; |
| 92 | 86 | } |
| 93 | 87 | |
| 94 | - /** | |
| 95 | - * @see wpdb::get_col | |
| 96 | - */ | |
| 97 | 88 | public function getColumn(?string $query = null, int $column = 0): array |
| 98 | 89 | { |
| 99 | 90 | return $this->wpDatabase->get_col($query, $column); |
| 100 | 91 | } |
| 101 | 92 | |
| 102 | - /** | |
| 103 | - * @see wpdb::get_row | |
| 104 | - */ | |
| 105 | 93 | public function getRow(?string $query = null, string $output = OBJECT, int $row = 0): object|array|null |
| 106 | 94 | { |
| 107 | 95 | return $this->wpDatabase->get_row($query, $output, $row); |
| 108 | 96 | } |
| 109 | 97 | |
| 110 | - /** | |
| 111 | - * @see wpdb::get_var | |
| 112 | - */ | |
| 113 | 98 | public function getVariable(?string $query = null, int $column = 0, int $row = 0): int|string|null |
| 114 | 99 | { |
| 115 | 100 | return $this->wpDatabase->get_var($query, $column, $row); |
| 116 | 101 | } |
| 117 | 102 | |
| 118 | - /** | |
| 119 | - * @see wpdb::get_blog_prefix | |
| 120 | - */ | |
| 121 | 103 | public function getBlogPrefix(int|string|null $blogId = null): string |
| 122 | 104 | { |
| 123 | 105 | return $this->wpDatabase->get_blog_prefix($blogId); |
| 124 | 106 | } |
| 125 | 107 | |
| 126 | - /** | |
| 127 | - * @see wpdb::prepare | |
| 128 | - */ | |
| 129 | 108 | public function prepare(string $query, mixed $arguments): string |
| 130 | 109 | { |
| 131 | 110 | return $this->wpDatabase->prepare($query, $arguments); |
| 132 | 111 | } |
| 133 | 112 | |
| 134 | - /** | |
| 135 | - * @see wpdb::query | |
| 136 | - */ | |
| 137 | 113 | public function query(string $query): bool|int |
| 138 | 114 | { |
| 139 | 115 | return $this->wpDatabase->query($query); |
| 140 | 116 | } |
| 141 | 117 | |
| 142 | - /** | |
| 143 | - * @see wpdb::get_results | |
| 144 | - */ | |
| 145 | 118 | public function getResults(?string $query = null, string $output = OBJECT): object|array|null |
| 146 | 119 | { |
| 147 | 120 | return $this->wpDatabase->get_results($query, $output); |
| 148 | 121 | } |
| 149 | 122 | |
| 150 | - /** | |
| 151 | - * @see wpdb::insert | |
| 152 | - */ | |
| 153 | - public function insert(string $table, array $data, $format = null): bool|int | |
| 123 | + public function insert(string $table, array $data, array|string|null $format = null): bool|int | |
| 154 | 124 | { |
| 155 | 125 | return $this->wpDatabase->insert($table, $data, $format); |
| 156 | 126 | } |
| 157 | 127 | |
| 158 | - /** | |
| 159 | - * @see wpdb::update | |
| 160 | - */ | |
| 161 | - public function update(string $table, array $data, array $where, $format = null, $whereFormat = null): bool|int | |
| 162 | - { | |
| 128 | + public function update( | |
| 129 | + string $table, | |
| 130 | + array $data, | |
| 131 | + array $where, | |
| 132 | + array|string|null $format = null, | |
| 133 | + array|string|null $whereFormat = null | |
| 134 | + ): bool|int { | |
| 163 | 135 | return $this->wpDatabase->update($table, $data, $where, $format, $whereFormat); |
| 164 | 136 | } |
| 165 | 137 | |
| 166 | - /** | |
| 167 | - * @see wpdb::insert | |
| 168 | - */ | |
| 169 | - public function replace(string $table, array $data, $format = null): bool|int | |
| 138 | + public function replace(string $table, array $data, array|string|null $format = null): bool|int | |
| 170 | 139 | { |
| 171 | 140 | return $this->wpDatabase->replace($table, $data, $format); |
| 172 | 141 | } |
| 173 | 142 | |
| 143 | + public function delete(string $table, array $where, array|string|null $whereFormat = null): bool|int | |
| 144 | + { | |
| 145 | + return $this->wpDatabase->delete($table, $where, $whereFormat); | |
| 146 | + } | |
| 147 | + | |
| 148 | + public function getCharset(): string | |
| 149 | + { | |
| 150 | + return $this->getCharsetCollate('DEFAULT '); | |
| 151 | + } | |
| 152 | + | |
| 174 | 153 | /** |
| 175 | - * @see wpdb::delete | |
| 154 | + * The charset clause for a column definition. It carries no DEFAULT, because that | |
| 155 | + * makes it a table option, which a column definition does not accept. | |
| 176 | 156 | */ |
| 177 | - public function delete(string $table, array $where, $whereFormat = null): bool|int | |
| 157 | + public function getColumnCharset(): string | |
| 178 | 158 | { |
| 179 | - return $this->wpDatabase->delete($table, $where, $whereFormat); | |
| 159 | + return $this->getCharsetCollate(''); | |
| 180 | 160 | } |
| 181 | 161 | |
| 182 | - public function getCharset(): string | |
| 162 | + private function getCharsetCollate(string $charsetPrefix): string | |
| 183 | 163 | { |
| 164 | + $mySqlVersion = (string) $this->getVariable('SELECT VERSION() as mysql_version'); | |
| 165 | + | |
| 166 | + if (version_compare($mySqlVersion, '4.1.0', '<')) { | |
| 167 | + return ''; | |
| 168 | + } | |
| 169 | + | |
| 184 | 170 | $charsetCollate = ''; |
| 185 | 171 | |
| 186 | - $mySlqVersion = (string) $this->getVariable('SELECT VERSION() as mysql_version'); | |
| 172 | + if (!empty($this->wpDatabase->charset)) { | |
| 173 | + $charsetCollate = "{$charsetPrefix}CHARACTER SET {$this->wpDatabase->charset}"; | |
| 174 | + } | |
| 187 | 175 | |
| 188 | - if (version_compare($mySlqVersion, '4.1.0', '>=')) { | |
| 189 | - if (!empty($this->wpDatabase->charset)) { | |
| 190 | - $charsetCollate = "DEFAULT CHARACTER SET {$this->wpDatabase->charset}"; | |
| 191 | - } | |
| 192 | - | |
| 193 | - if (!empty($this->wpDatabase->collate)) { | |
| 194 | - $charsetCollate .= " COLLATE {$this->wpDatabase->collate}"; | |
| 195 | - } | |
| 176 | + if (!empty($this->wpDatabase->collate)) { | |
| 177 | + $charsetCollate .= " COLLATE {$this->wpDatabase->collate}"; | |
| 196 | 178 | } |
| 197 | 179 | |
| 198 | 180 | return $charsetCollate; |
| 199 | 181 | } |