| @@ -146,8 +146,22 @@ | ||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function getCharset(): string |
| 149 | 149 | { |
| 150 | + return $this->getCharsetCollate('DEFAULT '); | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 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. | |
| 156 | + */ | |
| 157 | + public function getColumnCharset(): string | |
| 158 | + { | |
| 159 | + return $this->getCharsetCollate(''); | |
| 160 | + } | |
| 161 | + | |
| 162 | + private function getCharsetCollate(string $charsetPrefix): string | |
| 163 | + { | |
| 150 | 164 | $mySqlVersion = (string) $this->getVariable('SELECT VERSION() as mysql_version'); |
| 151 | 165 | |
| 152 | 166 | if (version_compare($mySqlVersion, '4.1.0', '<')) { |
| 153 | 167 | return ''; |
| @@ -155,9 +169,9 @@ | ||
| 155 | 169 | |
| 156 | 170 | $charsetCollate = ''; |
| 157 | 171 | |
| 158 | 172 | if (!empty($this->wpDatabase->charset)) { |
| 159 | - $charsetCollate = "DEFAULT CHARACTER SET {$this->wpDatabase->charset}"; | |
| 173 | + $charsetCollate = "{$charsetPrefix}CHARACTER SET {$this->wpDatabase->charset}"; | |
| 160 | 174 | } |
| 161 | 175 | |
| 162 | 176 | if (!empty($this->wpDatabase->collate)) { |
| 163 | 177 | $charsetCollate .= " COLLATE {$this->wpDatabase->collate}"; |