|
2 | 2 |
|
3 | 3 | namespace Camcima\MySqlDiff\Model; |
4 | 4 |
|
| 5 | +/** |
| 6 | + * Class Table |
| 7 | + * |
| 8 | + * @package Camcima\MySqlDiff\Model |
| 9 | + */ |
5 | 10 | class Table |
6 | 11 | { |
7 | 12 | /** |
@@ -49,6 +54,16 @@ class Table |
49 | 54 | */ |
50 | 55 | private $engine; |
51 | 56 |
|
| 57 | + /** |
| 58 | + * @var string |
| 59 | + */ |
| 60 | + private $rowFormat; |
| 61 | + |
| 62 | + /** |
| 63 | + * @var string |
| 64 | + */ |
| 65 | + private $keyBlockSize; |
| 66 | + |
52 | 67 | /** |
53 | 68 | * @var int |
54 | 69 | */ |
@@ -155,32 +170,32 @@ public function addColumn(Column $column) |
155 | 170 |
|
156 | 171 | /** |
157 | 172 | * @param string $columnName |
158 | | - * |
159 | 173 | * @return Column |
| 174 | + * @throws \RuntimeException |
160 | 175 | */ |
161 | 176 | public function getColumnByName($columnName) |
162 | 177 | { |
163 | 178 | if (!isset($this->columns[$columnName])) { |
164 | | - throw new \RuntimeException(sprintf('Column "%s" not found in table ""!', $columnName, $this->name)); |
| 179 | + throw new \RuntimeException(sprintf('Column "%s" not found in table "%s"!', $columnName, $this->name)); |
165 | 180 | } |
166 | 181 |
|
167 | 182 | return $this->columns[$columnName]; |
168 | 183 | } |
169 | 184 |
|
170 | 185 | /** |
171 | 186 | * @param int $columnOrder |
172 | | - * |
173 | 187 | * @return Column |
| 188 | + * @throws \RuntimeException |
174 | 189 | */ |
175 | 190 | public function getColumnByOrder($columnOrder) |
176 | 191 | { |
177 | 192 | foreach ($this->columns as $column) { |
178 | | - if ($column->getOrder() == $columnOrder) { |
| 193 | + if ($column->getOrder() === $columnOrder) { |
179 | 194 | return $column; |
180 | 195 | } |
181 | 196 | } |
182 | 197 |
|
183 | | - throw new \RuntimeException(sprintf('Column order "%s" not found in table ""!', $columnOrder, $this->name)); |
| 198 | + throw new \RuntimeException(sprintf('Column order "%s" not found in table "%s"!', $columnOrder, $this->name)); |
184 | 199 | } |
185 | 200 |
|
186 | 201 | /** |
@@ -228,13 +243,13 @@ public function addForeignKey(ForeignKey $foreignKey) |
228 | 243 |
|
229 | 244 | /** |
230 | 245 | * @param string $foreignKeyName |
231 | | - * |
232 | 246 | * @return ForeignKey |
| 247 | + * @throws \RuntimeException |
233 | 248 | */ |
234 | 249 | public function getForeignKeyByName($foreignKeyName) |
235 | 250 | { |
236 | 251 | if (!isset($this->foreignKeys[$foreignKeyName])) { |
237 | | - throw new \RuntimeException(sprintf('Foreign key "%s" not found in table ""!', $foreignKeyName, $this->name)); |
| 252 | + throw new \RuntimeException(sprintf('Foreign key "%s" not found in table "%s"!', $foreignKeyName, $this->name)); |
238 | 253 | } |
239 | 254 |
|
240 | 255 | return $this->foreignKeys[$foreignKeyName]; |
@@ -269,13 +284,13 @@ public function addIndex(Index $index) |
269 | 284 |
|
270 | 285 | /** |
271 | 286 | * @param string $indexName |
272 | | - * |
273 | 287 | * @return Index |
| 288 | + * @throws \RuntimeException |
274 | 289 | */ |
275 | 290 | public function getIndexByName($indexName) |
276 | 291 | { |
277 | 292 | if (!isset($this->indexes[$indexName])) { |
278 | | - throw new \RuntimeException(sprintf('Index "%s" not found in table ""!', $indexName, $this->name)); |
| 293 | + throw new \RuntimeException(sprintf('Index "%s" not found in table "%s"!', $indexName, $this->name)); |
279 | 294 | } |
280 | 295 |
|
281 | 296 | return $this->indexes[$indexName]; |
@@ -307,6 +322,38 @@ public function setEngine($engine) |
307 | 322 | $this->engine = $engine; |
308 | 323 | } |
309 | 324 |
|
| 325 | + /** |
| 326 | + * @return string |
| 327 | + */ |
| 328 | + public function getRowFormat() |
| 329 | + { |
| 330 | + return $this->rowFormat; |
| 331 | + } |
| 332 | + |
| 333 | + /** |
| 334 | + * @param string $rowFormat |
| 335 | + */ |
| 336 | + public function setRowFormat($rowFormat) |
| 337 | + { |
| 338 | + $this->rowFormat = $rowFormat; |
| 339 | + } |
| 340 | + |
| 341 | + /** |
| 342 | + * @return string |
| 343 | + */ |
| 344 | + public function getKeyBlockSize() |
| 345 | + { |
| 346 | + return $this->keyBlockSize; |
| 347 | + } |
| 348 | + |
| 349 | + /** |
| 350 | + * @param string $keyBlockSize |
| 351 | + */ |
| 352 | + public function setKeyBlockSize($keyBlockSize) |
| 353 | + { |
| 354 | + $this->keyBlockSize = $keyBlockSize; |
| 355 | + } |
| 356 | + |
310 | 357 | /** |
311 | 358 | * @return int |
312 | 359 | */ |
@@ -436,6 +483,14 @@ public function generateCreationScript($ignoreAutoIncrement = false, $sortKeys = |
436 | 483 | $tableOptions[] = sprintf('DEFAULT CHARSET=%s', $this->defaultCharset); |
437 | 484 | } |
438 | 485 |
|
| 486 | + if ($this->rowFormat) { |
| 487 | + $tableOptions[] = sprintf('ROW_FORMAT=%s', $this->rowFormat); |
| 488 | + } |
| 489 | + |
| 490 | + if ($this->keyBlockSize) { |
| 491 | + $tableOptions[] = sprintf('KEY_BLOCK_SIZE=%s', $this->keyBlockSize); |
| 492 | + } |
| 493 | + |
439 | 494 | if ($this->comment) { |
440 | 495 | $tableOptions[] = sprintf('COMMENT=\'%s\'', str_replace('\'','\'\'', $this->comment)); |
441 | 496 | } |
|
0 commit comments