| @@ 2492-2505 (lines=14) @@ | ||
| 2489 | * |
|
| 2490 | * @throws \InvalidArgumentException if unknown referential action given |
|
| 2491 | */ |
|
| 2492 | public function getForeignKeyReferentialActionSQL($action) |
|
| 2493 | { |
|
| 2494 | $upper = strtoupper($action); |
|
| 2495 | switch ($upper) { |
|
| 2496 | case 'CASCADE': |
|
| 2497 | case 'SET NULL': |
|
| 2498 | case 'NO ACTION': |
|
| 2499 | case 'RESTRICT': |
|
| 2500 | case 'SET DEFAULT': |
|
| 2501 | return $upper; |
|
| 2502 | default: |
|
| 2503 | throw new \InvalidArgumentException('Invalid foreign key action: ' . $upper); |
|
| 2504 | } |
|
| 2505 | } |
|
| 2506 | ||
| 2507 | /** |
|
| 2508 | * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
|
| @@ 733-752 (lines=20) @@ | ||
| 730 | /** |
|
| 731 | * {@inheritdoc} |
|
| 732 | */ |
|
| 733 | public function getForeignKeyReferentialActionSQL($action) |
|
| 734 | { |
|
| 735 | $action = strtoupper($action); |
|
| 736 | ||
| 737 | switch ($action) { |
|
| 738 | case 'RESTRICT': // RESTRICT is not supported, therefore falling back to NO ACTION. |
|
| 739 | case 'NO ACTION': |
|
| 740 | // NO ACTION cannot be declared explicitly, |
|
| 741 | // therefore returning empty string to indicate to OMIT the referential clause. |
|
| 742 | return ''; |
|
| 743 | ||
| 744 | case 'CASCADE': |
|
| 745 | case 'SET NULL': |
|
| 746 | return $action; |
|
| 747 | ||
| 748 | default: |
|
| 749 | // SET DEFAULT is not supported, throw exception instead. |
|
| 750 | throw new \InvalidArgumentException('Invalid foreign key action: ' . $action); |
|
| 751 | } |
|
| 752 | } |
|
| 753 | ||
| 754 | /** |
|
| 755 | * {@inheritDoc} |
|