|
64 | 64 | * limit?: bool, |
65 | 65 | * offset?: bool, |
66 | 66 | * order?: bool, |
67 | | - * querytype: ('ALTER'|'ANALYZE'|'CALL'|'CHECK'|'CHECKSUM'|'CREATE'|'DELETE'|'DROP'|'EXPLAIN'|'INSERT'|'LOAD'|'OPTIMIZE'|'REPAIR'|'REPLACE'|'SELECT'|'SET'|'SHOW'|'UPDATE'|false), |
| 67 | + * querytype: StatementType|null, |
68 | 68 | * reload?: bool, |
69 | 69 | * select_from?: bool, |
70 | 70 | * union?: bool |
@@ -114,7 +114,7 @@ class Query |
114 | 114 | * limit: false, |
115 | 115 | * offset: false, |
116 | 116 | * order: false, |
117 | | - * querytype: false, |
| 117 | + * querytype: null, |
118 | 118 | * reload: false, |
119 | 119 | * select_from: false, |
120 | 120 | * union: false |
@@ -258,7 +258,7 @@ class Query |
258 | 258 | * The type of the query (which is usually the first keyword of |
259 | 259 | * the statement). |
260 | 260 | */ |
261 | | - 'querytype' => false, |
| 261 | + 'querytype' => null, |
262 | 262 |
|
263 | 263 | /* |
264 | 264 | * Whether a page reload is required. |
@@ -288,7 +288,7 @@ class Query |
288 | 288 | */ |
289 | 289 | private static function getFlagsSelect(SelectStatement $statement, array $flags): array |
290 | 290 | { |
291 | | - $flags['querytype'] = 'SELECT'; |
| 291 | + $flags['querytype'] = StatementType::Select; |
292 | 292 | $flags['is_select'] = true; |
293 | 293 |
|
294 | 294 | if ($statement->from !== []) { |
@@ -364,72 +364,72 @@ private static function getFlagsSelect(SelectStatement $statement, array $flags) |
364 | 364 | */ |
365 | 365 | public static function getFlags(Statement|null $statement, bool $all = false): array |
366 | 366 | { |
367 | | - $flags = ['querytype' => false]; |
| 367 | + $flags = ['querytype' => null]; |
368 | 368 | if ($all) { |
369 | 369 | $flags = self::$allFlags; |
370 | 370 | } |
371 | 371 |
|
372 | 372 | if ($statement instanceof AlterStatement) { |
373 | | - $flags['querytype'] = 'ALTER'; |
| 373 | + $flags['querytype'] = StatementType::Alter; |
374 | 374 | $flags['reload'] = true; |
375 | 375 | } elseif ($statement instanceof CreateStatement) { |
376 | | - $flags['querytype'] = 'CREATE'; |
| 376 | + $flags['querytype'] = StatementType::Create; |
377 | 377 | $flags['reload'] = true; |
378 | 378 | } elseif ($statement instanceof AnalyzeStatement) { |
379 | | - $flags['querytype'] = 'ANALYZE'; |
| 379 | + $flags['querytype'] = StatementType::Analyze; |
380 | 380 | $flags['is_maint'] = true; |
381 | 381 | } elseif ($statement instanceof CheckStatement) { |
382 | | - $flags['querytype'] = 'CHECK'; |
| 382 | + $flags['querytype'] = StatementType::Check; |
383 | 383 | $flags['is_maint'] = true; |
384 | 384 | } elseif ($statement instanceof ChecksumStatement) { |
385 | | - $flags['querytype'] = 'CHECKSUM'; |
| 385 | + $flags['querytype'] = StatementType::Checksum; |
386 | 386 | $flags['is_maint'] = true; |
387 | 387 | } elseif ($statement instanceof OptimizeStatement) { |
388 | | - $flags['querytype'] = 'OPTIMIZE'; |
| 388 | + $flags['querytype'] = StatementType::Optimize; |
389 | 389 | $flags['is_maint'] = true; |
390 | 390 | } elseif ($statement instanceof RepairStatement) { |
391 | | - $flags['querytype'] = 'REPAIR'; |
| 391 | + $flags['querytype'] = StatementType::Repair; |
392 | 392 | $flags['is_maint'] = true; |
393 | 393 | } elseif ($statement instanceof CallStatement) { |
394 | | - $flags['querytype'] = 'CALL'; |
| 394 | + $flags['querytype'] = StatementType::Call; |
395 | 395 | $flags['is_procedure'] = true; |
396 | 396 | } elseif ($statement instanceof DeleteStatement) { |
397 | | - $flags['querytype'] = 'DELETE'; |
| 397 | + $flags['querytype'] = StatementType::Delete; |
398 | 398 | $flags['is_delete'] = true; |
399 | 399 | $flags['is_affected'] = true; |
400 | 400 | } elseif ($statement instanceof DropStatement) { |
401 | | - $flags['querytype'] = 'DROP'; |
| 401 | + $flags['querytype'] = StatementType::Drop; |
402 | 402 | $flags['reload'] = true; |
403 | 403 |
|
404 | 404 | if ($statement->options->has('DATABASE') || $statement->options->has('SCHEMA')) { |
405 | 405 | $flags['drop_database'] = true; |
406 | 406 | } |
407 | 407 | } elseif ($statement instanceof ExplainStatement) { |
408 | | - $flags['querytype'] = 'EXPLAIN'; |
| 408 | + $flags['querytype'] = StatementType::Explain; |
409 | 409 | $flags['is_explain'] = true; |
410 | 410 | } elseif ($statement instanceof InsertStatement) { |
411 | | - $flags['querytype'] = 'INSERT'; |
| 411 | + $flags['querytype'] = StatementType::Insert; |
412 | 412 | $flags['is_affected'] = true; |
413 | 413 | $flags['is_insert'] = true; |
414 | 414 | } elseif ($statement instanceof LoadStatement) { |
415 | | - $flags['querytype'] = 'LOAD'; |
| 415 | + $flags['querytype'] = StatementType::Load; |
416 | 416 | $flags['is_affected'] = true; |
417 | 417 | $flags['is_insert'] = true; |
418 | 418 | } elseif ($statement instanceof ReplaceStatement) { |
419 | | - $flags['querytype'] = 'REPLACE'; |
| 419 | + $flags['querytype'] = StatementType::Replace; |
420 | 420 | $flags['is_affected'] = true; |
421 | 421 | $flags['is_replace'] = true; |
422 | 422 | $flags['is_insert'] = true; |
423 | 423 | } elseif ($statement instanceof SelectStatement) { |
424 | 424 | $flags = self::getFlagsSelect($statement, $flags); |
425 | 425 | } elseif ($statement instanceof ShowStatement) { |
426 | | - $flags['querytype'] = 'SHOW'; |
| 426 | + $flags['querytype'] = StatementType::Show; |
427 | 427 | $flags['is_show'] = true; |
428 | 428 | } elseif ($statement instanceof UpdateStatement) { |
429 | | - $flags['querytype'] = 'UPDATE'; |
| 429 | + $flags['querytype'] = StatementType::Update; |
430 | 430 | $flags['is_affected'] = true; |
431 | 431 | } elseif ($statement instanceof SetStatement) { |
432 | | - $flags['querytype'] = 'SET'; |
| 432 | + $flags['querytype'] = StatementType::Set; |
433 | 433 | } |
434 | 434 |
|
435 | 435 | if ( |
|
0 commit comments