Complex classes like AbstractPlatform often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractPlatform, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 66 | abstract class AbstractPlatform |
||
| 67 | { |
||
| 68 | public const CREATE_INDEXES = 1; |
||
| 69 | |||
| 70 | public const CREATE_FOREIGNKEYS = 2; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @deprecated Use DateIntervalUnit::INTERVAL_UNIT_SECOND. |
||
| 74 | */ |
||
| 75 | public const DATE_INTERVAL_UNIT_SECOND = DateIntervalUnit::SECOND; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @deprecated Use DateIntervalUnit::MINUTE. |
||
| 79 | */ |
||
| 80 | public const DATE_INTERVAL_UNIT_MINUTE = DateIntervalUnit::MINUTE; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @deprecated Use DateIntervalUnit::HOUR. |
||
| 84 | */ |
||
| 85 | public const DATE_INTERVAL_UNIT_HOUR = DateIntervalUnit::HOUR; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @deprecated Use DateIntervalUnit::DAY. |
||
| 89 | */ |
||
| 90 | public const DATE_INTERVAL_UNIT_DAY = DateIntervalUnit::DAY; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @deprecated Use DateIntervalUnit::WEEK. |
||
| 94 | */ |
||
| 95 | public const DATE_INTERVAL_UNIT_WEEK = DateIntervalUnit::WEEK; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @deprecated Use DateIntervalUnit::MONTH. |
||
| 99 | */ |
||
| 100 | public const DATE_INTERVAL_UNIT_MONTH = DateIntervalUnit::MONTH; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @deprecated Use DateIntervalUnit::QUARTER. |
||
| 104 | */ |
||
| 105 | public const DATE_INTERVAL_UNIT_QUARTER = DateIntervalUnit::QUARTER; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @deprecated Use DateIntervalUnit::QUARTER. |
||
| 109 | */ |
||
| 110 | public const DATE_INTERVAL_UNIT_YEAR = DateIntervalUnit::YEAR; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @deprecated Use TrimMode::UNSPECIFIED. |
||
| 114 | */ |
||
| 115 | public const TRIM_UNSPECIFIED = TrimMode::UNSPECIFIED; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @deprecated Use TrimMode::LEADING. |
||
| 119 | */ |
||
| 120 | public const TRIM_LEADING = TrimMode::LEADING; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @deprecated Use TrimMode::TRAILING. |
||
| 124 | */ |
||
| 125 | public const TRIM_TRAILING = TrimMode::TRAILING; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @deprecated Use TrimMode::BOTH. |
||
| 129 | */ |
||
| 130 | public const TRIM_BOTH = TrimMode::BOTH; |
||
| 131 | |||
| 132 | /** @var string[]|null */ |
||
| 133 | protected $doctrineTypeMapping = null; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Contains a list of all columns that should generate parseable column comments for type-detection |
||
| 137 | * in reverse engineering scenarios. |
||
| 138 | * |
||
| 139 | * @var string[]|null |
||
| 140 | */ |
||
| 141 | protected $doctrineTypeComments = null; |
||
| 142 | |||
| 143 | /** @var EventManager */ |
||
| 144 | protected $_eventManager; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Holds the KeywordList instance for the current platform. |
||
| 148 | * |
||
| 149 | * @var KeywordList|null |
||
| 150 | */ |
||
| 151 | protected $_keywords; |
||
| 152 | |||
| 153 | 63754 | public function __construct() |
|
| 156 | |||
| 157 | /** |
||
| 158 | * Sets the EventManager used by the Platform. |
||
| 159 | * |
||
| 160 | * @return void |
||
| 161 | */ |
||
| 162 | 60319 | public function setEventManager(EventManager $eventManager) |
|
| 166 | |||
| 167 | /** |
||
| 168 | * Gets the EventManager used by the Platform. |
||
| 169 | * |
||
| 170 | * @return EventManager |
||
| 171 | */ |
||
| 172 | 57777 | public function getEventManager() |
|
| 176 | |||
| 177 | /** |
||
| 178 | * Returns the SQL snippet that declares a boolean column. |
||
| 179 | * |
||
| 180 | * @param mixed[] $columnDef |
||
| 181 | * |
||
| 182 | * @return string |
||
| 183 | */ |
||
| 184 | abstract public function getBooleanTypeDeclarationSQL(array $columnDef); |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Returns the SQL snippet that declares a 4 byte integer column. |
||
| 188 | * |
||
| 189 | * @param mixed[] $columnDef |
||
| 190 | * |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | abstract public function getIntegerTypeDeclarationSQL(array $columnDef); |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Returns the SQL snippet that declares an 8 byte integer column. |
||
| 197 | * |
||
| 198 | * @param mixed[] $columnDef |
||
| 199 | * |
||
| 200 | * @return string |
||
| 201 | */ |
||
| 202 | abstract public function getBigIntTypeDeclarationSQL(array $columnDef); |
||
| 203 | |||
| 204 | /** |
||
| 205 | * Returns the SQL snippet that declares a 2 byte integer column. |
||
| 206 | * |
||
| 207 | * @param mixed[] $columnDef |
||
| 208 | * |
||
| 209 | * @return string |
||
| 210 | */ |
||
| 211 | abstract public function getSmallIntTypeDeclarationSQL(array $columnDef); |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Returns the SQL snippet that declares common properties of an integer column. |
||
| 215 | * |
||
| 216 | * @param mixed[] $columnDef |
||
| 217 | * |
||
| 218 | * @return string |
||
| 219 | */ |
||
| 220 | abstract protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef); |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Lazy load Doctrine Type Mappings. |
||
| 224 | * |
||
| 225 | * @return void |
||
| 226 | */ |
||
| 227 | abstract protected function initializeDoctrineTypeMappings(); |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Initializes Doctrine Type Mappings with the platform defaults |
||
| 231 | * and with all additional type mappings. |
||
| 232 | * |
||
| 233 | * @return void |
||
| 234 | */ |
||
| 235 | 57815 | private function initializeAllDoctrineTypeMappings() |
|
| 245 | |||
| 246 | /** |
||
| 247 | * Returns the SQL snippet used to declare a VARCHAR column type. |
||
| 248 | * |
||
| 249 | * @param mixed[] $field |
||
| 250 | * |
||
| 251 | * @return string |
||
| 252 | */ |
||
| 253 | 59478 | public function getVarcharTypeDeclarationSQL(array $field) |
|
| 271 | |||
| 272 | /** |
||
| 273 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 274 | * |
||
| 275 | * @param mixed[] $field The column definition. |
||
| 276 | * |
||
| 277 | * @return string |
||
| 278 | */ |
||
| 279 | 56538 | public function getBinaryTypeDeclarationSQL(array $field) |
|
| 303 | |||
| 304 | /** |
||
| 305 | * Returns the SQL snippet to declare a GUID/UUID field. |
||
| 306 | * |
||
| 307 | * By default this maps directly to a CHAR(36) and only maps to more |
||
| 308 | * special datatypes when the underlying databases support this datatype. |
||
| 309 | * |
||
| 310 | * @param mixed[] $field |
||
| 311 | * |
||
| 312 | * @return string |
||
| 313 | */ |
||
| 314 | 55625 | public function getGuidTypeDeclarationSQL(array $field) |
|
| 321 | |||
| 322 | /** |
||
| 323 | * Returns the SQL snippet to declare a JSON field. |
||
| 324 | * |
||
| 325 | * By default this maps directly to a CLOB and only maps to more |
||
| 326 | * special datatypes when the underlying databases support this datatype. |
||
| 327 | * |
||
| 328 | * @param mixed[] $field |
||
| 329 | * |
||
| 330 | * @return string |
||
| 331 | */ |
||
| 332 | 53975 | public function getJsonTypeDeclarationSQL(array $field) |
|
| 336 | |||
| 337 | /** |
||
| 338 | * @param int $length |
||
| 339 | * @param bool $fixed |
||
| 340 | * |
||
| 341 | * @return string |
||
| 342 | * |
||
| 343 | * @throws DBALException If not supported on this platform. |
||
| 344 | */ |
||
| 345 | protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 352 | * |
||
| 353 | * @param int $length The length of the column. |
||
| 354 | * @param bool $fixed Whether the column length is fixed. |
||
| 355 | * |
||
| 356 | * @return string |
||
| 357 | * |
||
| 358 | * @throws DBALException If not supported on this platform. |
||
| 359 | */ |
||
| 360 | protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Returns the SQL snippet used to declare a CLOB column type. |
||
| 367 | * |
||
| 368 | * @param mixed[] $field |
||
| 369 | * |
||
| 370 | * @return string |
||
| 371 | */ |
||
| 372 | abstract public function getClobTypeDeclarationSQL(array $field); |
||
| 373 | |||
| 374 | /** |
||
| 375 | * Returns the SQL Snippet used to declare a BLOB column type. |
||
| 376 | * |
||
| 377 | * @param mixed[] $field |
||
| 378 | * |
||
| 379 | * @return string |
||
| 380 | */ |
||
| 381 | abstract public function getBlobTypeDeclarationSQL(array $field); |
||
| 382 | |||
| 383 | /** |
||
| 384 | * Gets the name of the platform. |
||
| 385 | * |
||
| 386 | * @return string |
||
| 387 | */ |
||
| 388 | abstract public function getName(); |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Registers a doctrine type to be used in conjunction with a column type of this platform. |
||
| 392 | * |
||
| 393 | * @param string $dbType |
||
| 394 | * @param string $doctrineType |
||
| 395 | * |
||
| 396 | * @return void |
||
| 397 | * |
||
| 398 | * @throws DBALException If the type is not found. |
||
| 399 | */ |
||
| 400 | 55931 | public function registerDoctrineTypeMapping($dbType, $doctrineType) |
|
| 421 | |||
| 422 | /** |
||
| 423 | * Gets the Doctrine type that is mapped for the given database column type. |
||
| 424 | * |
||
| 425 | * @param string $dbType |
||
| 426 | * |
||
| 427 | * @return string |
||
| 428 | * |
||
| 429 | * @throws DBALException |
||
| 430 | */ |
||
| 431 | 57833 | public function getDoctrineTypeMapping($dbType) |
|
| 445 | |||
| 446 | /** |
||
| 447 | * Checks if a database type is currently supported by this platform. |
||
| 448 | * |
||
| 449 | * @param string $dbType |
||
| 450 | * |
||
| 451 | * @return bool |
||
| 452 | */ |
||
| 453 | 55277 | public function hasDoctrineTypeMappingFor($dbType) |
|
| 463 | |||
| 464 | /** |
||
| 465 | * Initializes the Doctrine Type comments instance variable for in_array() checks. |
||
| 466 | * |
||
| 467 | * @return void |
||
| 468 | */ |
||
| 469 | 60395 | protected function initializeCommentedDoctrineTypes() |
|
| 483 | |||
| 484 | /** |
||
| 485 | * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type? |
||
| 486 | * |
||
| 487 | * @return bool |
||
| 488 | */ |
||
| 489 | 60530 | public function isCommentedDoctrineType(Type $doctrineType) |
|
| 499 | |||
| 500 | /** |
||
| 501 | * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements. |
||
| 502 | * |
||
| 503 | * @param string|Type $doctrineType |
||
| 504 | * |
||
| 505 | * @return void |
||
| 506 | */ |
||
| 507 | 53493 | public function markDoctrineTypeCommented($doctrineType) |
|
| 517 | |||
| 518 | /** |
||
| 519 | * Gets the comment to append to a column comment that helps parsing this type in reverse engineering. |
||
| 520 | * |
||
| 521 | * @return string |
||
| 522 | */ |
||
| 523 | 57004 | public function getDoctrineTypeComment(Type $doctrineType) |
|
| 527 | |||
| 528 | /** |
||
| 529 | * Gets the comment of a passed column modified by potential doctrine type comment hints. |
||
| 530 | * |
||
| 531 | * @return string|null |
||
| 532 | */ |
||
| 533 | 60063 | protected function getColumnComment(Column $column) |
|
| 543 | |||
| 544 | /** |
||
| 545 | * Gets the character used for identifier quoting. |
||
| 546 | * |
||
| 547 | * @return string |
||
| 548 | */ |
||
| 549 | 56190 | public function getIdentifierQuoteCharacter() |
|
| 553 | |||
| 554 | /** |
||
| 555 | * Gets the string portion that starts an SQL comment. |
||
| 556 | * |
||
| 557 | * @return string |
||
| 558 | */ |
||
| 559 | public function getSqlCommentStartString() |
||
| 563 | |||
| 564 | /** |
||
| 565 | * Gets the string portion that ends an SQL comment. |
||
| 566 | * |
||
| 567 | * @return string |
||
| 568 | */ |
||
| 569 | public function getSqlCommentEndString() |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Gets the maximum length of a char field. |
||
| 576 | */ |
||
| 577 | 57685 | public function getCharMaxLength() : int |
|
| 581 | |||
| 582 | /** |
||
| 583 | * Gets the maximum length of a varchar field. |
||
| 584 | * |
||
| 585 | * @return int |
||
| 586 | */ |
||
| 587 | 55241 | public function getVarcharMaxLength() |
|
| 591 | |||
| 592 | /** |
||
| 593 | * Gets the default length of a varchar field. |
||
| 594 | * |
||
| 595 | * @return int |
||
| 596 | */ |
||
| 597 | 56286 | public function getVarcharDefaultLength() |
|
| 601 | |||
| 602 | /** |
||
| 603 | * Gets the maximum length of a binary field. |
||
| 604 | * |
||
| 605 | * @return int |
||
| 606 | */ |
||
| 607 | public function getBinaryMaxLength() |
||
| 611 | |||
| 612 | /** |
||
| 613 | * Gets the default length of a binary field. |
||
| 614 | * |
||
| 615 | * @return int |
||
| 616 | */ |
||
| 617 | 54364 | public function getBinaryDefaultLength() |
|
| 621 | |||
| 622 | /** |
||
| 623 | * Gets all SQL wildcard characters of the platform. |
||
| 624 | * |
||
| 625 | * @return string[] |
||
| 626 | */ |
||
| 627 | public function getWildcards() |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Returns the regular expression operator. |
||
| 634 | * |
||
| 635 | * @return string |
||
| 636 | * |
||
| 637 | * @throws DBALException If not supported on this platform. |
||
| 638 | */ |
||
| 639 | 43728 | public function getRegexpExpression() |
|
| 643 | |||
| 644 | /** |
||
| 645 | * Returns the global unique identifier expression. |
||
| 646 | * |
||
| 647 | * @deprecated Use application-generated UUIDs instead |
||
| 648 | * |
||
| 649 | * @return string |
||
| 650 | * |
||
| 651 | * @throws DBALException If not supported on this platform. |
||
| 652 | */ |
||
| 653 | public function getGuidExpression() |
||
| 657 | |||
| 658 | /** |
||
| 659 | * Returns the SQL snippet to get the average value of a column. |
||
| 660 | * |
||
| 661 | * @param string $column The column to use. |
||
| 662 | * |
||
| 663 | * @return string Generated SQL including an AVG aggregate function. |
||
| 664 | */ |
||
| 665 | public function getAvgExpression($column) |
||
| 669 | |||
| 670 | /** |
||
| 671 | * Returns the SQL snippet to get the number of rows (without a NULL value) of a column. |
||
| 672 | * |
||
| 673 | * If a '*' is used instead of a column the number of selected rows is returned. |
||
| 674 | * |
||
| 675 | * @param string|int $column The column to use. |
||
| 676 | * |
||
| 677 | * @return string Generated SQL including a COUNT aggregate function. |
||
| 678 | */ |
||
| 679 | public function getCountExpression($column) |
||
| 683 | |||
| 684 | /** |
||
| 685 | * Returns the SQL snippet to get the highest value of a column. |
||
| 686 | * |
||
| 687 | * @param string $column The column to use. |
||
| 688 | * |
||
| 689 | * @return string Generated SQL including a MAX aggregate function. |
||
| 690 | */ |
||
| 691 | public function getMaxExpression($column) |
||
| 695 | |||
| 696 | /** |
||
| 697 | * Returns the SQL snippet to get the lowest value of a column. |
||
| 698 | * |
||
| 699 | * @param string $column The column to use. |
||
| 700 | * |
||
| 701 | * @return string Generated SQL including a MIN aggregate function. |
||
| 702 | */ |
||
| 703 | public function getMinExpression($column) |
||
| 707 | |||
| 708 | /** |
||
| 709 | * Returns the SQL snippet to get the total sum of a column. |
||
| 710 | * |
||
| 711 | * @param string $column The column to use. |
||
| 712 | * |
||
| 713 | * @return string Generated SQL including a SUM aggregate function. |
||
| 714 | */ |
||
| 715 | public function getSumExpression($column) |
||
| 719 | |||
| 720 | // scalar functions |
||
| 721 | |||
| 722 | /** |
||
| 723 | * Returns the SQL snippet to get the md5 sum of a field. |
||
| 724 | * |
||
| 725 | * Note: Not SQL92, but common functionality. |
||
| 726 | * |
||
| 727 | * @param string $column |
||
| 728 | * |
||
| 729 | * @return string |
||
| 730 | */ |
||
| 731 | public function getMd5Expression($column) |
||
| 735 | |||
| 736 | /** |
||
| 737 | * Returns the SQL snippet to get the length of a text field. |
||
| 738 | * |
||
| 739 | * @param string $column |
||
| 740 | * |
||
| 741 | * @return string |
||
| 742 | */ |
||
| 743 | public function getLengthExpression($column) |
||
| 747 | |||
| 748 | /** |
||
| 749 | * Returns the SQL snippet to get the squared value of a column. |
||
| 750 | * |
||
| 751 | * @param string $column The column to use. |
||
| 752 | * |
||
| 753 | * @return string Generated SQL including an SQRT aggregate function. |
||
| 754 | */ |
||
| 755 | public function getSqrtExpression($column) |
||
| 759 | |||
| 760 | /** |
||
| 761 | * Returns the SQL snippet to round a numeric field to the number of decimals specified. |
||
| 762 | * |
||
| 763 | * @param string $column |
||
| 764 | * @param int $decimals |
||
| 765 | * |
||
| 766 | * @return string |
||
| 767 | */ |
||
| 768 | public function getRoundExpression($column, $decimals = 0) |
||
| 772 | |||
| 773 | /** |
||
| 774 | * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2. |
||
| 775 | * |
||
| 776 | * @param string $expression1 |
||
| 777 | * @param string $expression2 |
||
| 778 | * |
||
| 779 | * @return string |
||
| 780 | */ |
||
| 781 | public function getModExpression($expression1, $expression2) |
||
| 785 | |||
| 786 | /** |
||
| 787 | * Returns the SQL snippet to trim a string. |
||
| 788 | * |
||
| 789 | * @param string $str The expression to apply the trim to. |
||
| 790 | * @param int $mode The position of the trim (leading/trailing/both). |
||
| 791 | * @param string|bool $char The char to trim, has to be quoted already. Defaults to space. |
||
| 792 | * |
||
| 793 | * @return string |
||
| 794 | */ |
||
| 795 | 51382 | public function getTrimExpression($str, $mode = TrimMode::UNSPECIFIED, $char = false) |
|
| 823 | |||
| 824 | /** |
||
| 825 | * Returns the SQL snippet to trim trailing space characters from the expression. |
||
| 826 | * |
||
| 827 | * @param string $str Literal string or column name. |
||
| 828 | * |
||
| 829 | * @return string |
||
| 830 | */ |
||
| 831 | 25764 | public function getRtrimExpression($str) |
|
| 835 | |||
| 836 | /** |
||
| 837 | * Returns the SQL snippet to trim leading space characters from the expression. |
||
| 838 | * |
||
| 839 | * @param string $str Literal string or column name. |
||
| 840 | * |
||
| 841 | * @return string |
||
| 842 | */ |
||
| 843 | 25764 | public function getLtrimExpression($str) |
|
| 847 | |||
| 848 | /** |
||
| 849 | * Returns the SQL snippet to change all characters from the expression to uppercase, |
||
| 850 | * according to the current character set mapping. |
||
| 851 | * |
||
| 852 | * @param string $str Literal string or column name. |
||
| 853 | * |
||
| 854 | * @return string |
||
| 855 | */ |
||
| 856 | public function getUpperExpression($str) |
||
| 860 | |||
| 861 | /** |
||
| 862 | * Returns the SQL snippet to change all characters from the expression to lowercase, |
||
| 863 | * according to the current character set mapping. |
||
| 864 | * |
||
| 865 | * @param string $str Literal string or column name. |
||
| 866 | * |
||
| 867 | * @return string |
||
| 868 | */ |
||
| 869 | public function getLowerExpression($str) |
||
| 873 | |||
| 874 | /** |
||
| 875 | * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. |
||
| 876 | * |
||
| 877 | * @param string $str Literal string. |
||
| 878 | * @param string $substr Literal string to find. |
||
| 879 | * @param int|false $startPos Position to start at, beginning of string by default. |
||
| 880 | * |
||
| 881 | * @return string |
||
| 882 | * |
||
| 883 | * @throws DBALException If not supported on this platform. |
||
| 884 | */ |
||
| 885 | public function getLocateExpression($str, $substr, $startPos = false) |
||
| 889 | |||
| 890 | /** |
||
| 891 | * Returns the SQL snippet to get the current system date. |
||
| 892 | * |
||
| 893 | * @return string |
||
| 894 | */ |
||
| 895 | public function getNowExpression() |
||
| 899 | |||
| 900 | /** |
||
| 901 | * Returns a SQL snippet to get a substring inside an SQL statement. |
||
| 902 | * |
||
| 903 | * Note: Not SQL92, but common functionality. |
||
| 904 | * |
||
| 905 | * SQLite only supports the 2 parameter variant of this function. |
||
| 906 | * |
||
| 907 | * @param string $value An sql string literal or column name/alias. |
||
| 908 | * @param int $from Where to start the substring portion. |
||
| 909 | * @param int|null $length The substring portion length. |
||
| 910 | * |
||
| 911 | * @return string |
||
| 912 | */ |
||
| 913 | public function getSubstringExpression($value, $from, $length = null) |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Returns a SQL snippet to concatenate the given expressions. |
||
| 924 | * |
||
| 925 | * Accepts an arbitrary number of string parameters. Each parameter must contain an expression. |
||
| 926 | * |
||
| 927 | * @return string |
||
| 928 | */ |
||
| 929 | 43706 | public function getConcatExpression() |
|
| 933 | |||
| 934 | /** |
||
| 935 | * Returns the SQL for a logical not. |
||
| 936 | * |
||
| 937 | * Example: |
||
| 938 | * <code> |
||
| 939 | * $q = new Doctrine_Query(); |
||
| 940 | * $e = $q->expr; |
||
| 941 | * $q->select('*')->from('table') |
||
| 942 | * ->where($e->eq('id', $e->not('null')); |
||
| 943 | * </code> |
||
| 944 | * |
||
| 945 | * @param string $expression |
||
| 946 | * |
||
| 947 | * @return string The logical expression. |
||
| 948 | */ |
||
| 949 | public function getNotExpression($expression) |
||
| 953 | |||
| 954 | /** |
||
| 955 | * Returns the SQL that checks if an expression is null. |
||
| 956 | * |
||
| 957 | * @param string $expression The expression that should be compared to null. |
||
| 958 | * |
||
| 959 | * @return string The logical expression. |
||
| 960 | */ |
||
| 961 | 60284 | public function getIsNullExpression($expression) |
|
| 965 | |||
| 966 | /** |
||
| 967 | * Returns the SQL that checks if an expression is not null. |
||
| 968 | * |
||
| 969 | * @param string $expression The expression that should be compared to null. |
||
| 970 | * |
||
| 971 | * @return string The logical expression. |
||
| 972 | */ |
||
| 973 | public function getIsNotNullExpression($expression) |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Returns the SQL that checks if an expression evaluates to a value between two values. |
||
| 980 | * |
||
| 981 | * The parameter $expression is checked if it is between $value1 and $value2. |
||
| 982 | * |
||
| 983 | * Note: There is a slight difference in the way BETWEEN works on some databases. |
||
| 984 | * http://www.w3schools.com/sql/sql_between.asp. If you want complete database |
||
| 985 | * independence you should avoid using between(). |
||
| 986 | * |
||
| 987 | * @param string $expression The value to compare to. |
||
| 988 | * @param string $value1 The lower value to compare with. |
||
| 989 | * @param string $value2 The higher value to compare with. |
||
| 990 | * |
||
| 991 | * @return string The logical expression. |
||
| 992 | */ |
||
| 993 | public function getBetweenExpression($expression, $value1, $value2) |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Returns the SQL to get the arccosine of a value. |
||
| 1000 | * |
||
| 1001 | * @param string $value |
||
| 1002 | * |
||
| 1003 | * @return string |
||
| 1004 | */ |
||
| 1005 | public function getAcosExpression($value) |
||
| 1009 | |||
| 1010 | /** |
||
| 1011 | * Returns the SQL to get the sine of a value. |
||
| 1012 | * |
||
| 1013 | * @param string $value |
||
| 1014 | * |
||
| 1015 | * @return string |
||
| 1016 | */ |
||
| 1017 | public function getSinExpression($value) |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Returns the SQL to get the PI value. |
||
| 1024 | * |
||
| 1025 | * @return string |
||
| 1026 | */ |
||
| 1027 | public function getPiExpression() |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * Returns the SQL to get the cosine of a value. |
||
| 1034 | * |
||
| 1035 | * @param string $value |
||
| 1036 | * |
||
| 1037 | * @return string |
||
| 1038 | */ |
||
| 1039 | public function getCosExpression($value) |
||
| 1043 | |||
| 1044 | /** |
||
| 1045 | * Returns the SQL to calculate the difference in days between the two passed dates. |
||
| 1046 | * |
||
| 1047 | * Computes diff = date1 - date2. |
||
| 1048 | * |
||
| 1049 | * @param string $date1 |
||
| 1050 | * @param string $date2 |
||
| 1051 | * |
||
| 1052 | * @return string |
||
| 1053 | * |
||
| 1054 | * @throws DBALException If not supported on this platform. |
||
| 1055 | */ |
||
| 1056 | public function getDateDiffExpression($date1, $date2) |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Returns the SQL to add the number of given seconds to a date. |
||
| 1063 | * |
||
| 1064 | * @param string $date |
||
| 1065 | * @param int $seconds |
||
| 1066 | * |
||
| 1067 | * @return string |
||
| 1068 | * |
||
| 1069 | * @throws DBALException If not supported on this platform. |
||
| 1070 | */ |
||
| 1071 | 58620 | public function getDateAddSecondsExpression($date, $seconds) |
|
| 1075 | |||
| 1076 | /** |
||
| 1077 | * Returns the SQL to subtract the number of given seconds from a date. |
||
| 1078 | * |
||
| 1079 | * @param string $date |
||
| 1080 | * @param int $seconds |
||
| 1081 | * |
||
| 1082 | * @return string |
||
| 1083 | * |
||
| 1084 | * @throws DBALException If not supported on this platform. |
||
| 1085 | */ |
||
| 1086 | 58620 | public function getDateSubSecondsExpression($date, $seconds) |
|
| 1090 | |||
| 1091 | /** |
||
| 1092 | * Returns the SQL to add the number of given minutes to a date. |
||
| 1093 | * |
||
| 1094 | * @param string $date |
||
| 1095 | * @param int $minutes |
||
| 1096 | * |
||
| 1097 | * @return string |
||
| 1098 | * |
||
| 1099 | * @throws DBALException If not supported on this platform. |
||
| 1100 | */ |
||
| 1101 | 58620 | public function getDateAddMinutesExpression($date, $minutes) |
|
| 1105 | |||
| 1106 | /** |
||
| 1107 | * Returns the SQL to subtract the number of given minutes from a date. |
||
| 1108 | * |
||
| 1109 | * @param string $date |
||
| 1110 | * @param int $minutes |
||
| 1111 | * |
||
| 1112 | * @return string |
||
| 1113 | * |
||
| 1114 | * @throws DBALException If not supported on this platform. |
||
| 1115 | */ |
||
| 1116 | 58620 | public function getDateSubMinutesExpression($date, $minutes) |
|
| 1120 | |||
| 1121 | /** |
||
| 1122 | * Returns the SQL to add the number of given hours to a date. |
||
| 1123 | * |
||
| 1124 | * @param string $date |
||
| 1125 | * @param int $hours |
||
| 1126 | * |
||
| 1127 | * @return string |
||
| 1128 | * |
||
| 1129 | * @throws DBALException If not supported on this platform. |
||
| 1130 | */ |
||
| 1131 | 58620 | public function getDateAddHourExpression($date, $hours) |
|
| 1135 | |||
| 1136 | /** |
||
| 1137 | * Returns the SQL to subtract the number of given hours to a date. |
||
| 1138 | * |
||
| 1139 | * @param string $date |
||
| 1140 | * @param int $hours |
||
| 1141 | * |
||
| 1142 | * @return string |
||
| 1143 | * |
||
| 1144 | * @throws DBALException If not supported on this platform. |
||
| 1145 | */ |
||
| 1146 | 58620 | public function getDateSubHourExpression($date, $hours) |
|
| 1150 | |||
| 1151 | /** |
||
| 1152 | * Returns the SQL to add the number of given days to a date. |
||
| 1153 | * |
||
| 1154 | * @param string $date |
||
| 1155 | * @param int $days |
||
| 1156 | * |
||
| 1157 | * @return string |
||
| 1158 | * |
||
| 1159 | * @throws DBALException If not supported on this platform. |
||
| 1160 | */ |
||
| 1161 | 58622 | public function getDateAddDaysExpression($date, $days) |
|
| 1165 | |||
| 1166 | /** |
||
| 1167 | * Returns the SQL to subtract the number of given days to a date. |
||
| 1168 | * |
||
| 1169 | * @param string $date |
||
| 1170 | * @param int $days |
||
| 1171 | * |
||
| 1172 | * @return string |
||
| 1173 | * |
||
| 1174 | * @throws DBALException If not supported on this platform. |
||
| 1175 | */ |
||
| 1176 | 58620 | public function getDateSubDaysExpression($date, $days) |
|
| 1180 | |||
| 1181 | /** |
||
| 1182 | * Returns the SQL to add the number of given weeks to a date. |
||
| 1183 | * |
||
| 1184 | * @param string $date |
||
| 1185 | * @param int $weeks |
||
| 1186 | * |
||
| 1187 | * @return string |
||
| 1188 | * |
||
| 1189 | * @throws DBALException If not supported on this platform. |
||
| 1190 | */ |
||
| 1191 | 58620 | public function getDateAddWeeksExpression($date, $weeks) |
|
| 1195 | |||
| 1196 | /** |
||
| 1197 | * Returns the SQL to subtract the number of given weeks from a date. |
||
| 1198 | * |
||
| 1199 | * @param string $date |
||
| 1200 | * @param int $weeks |
||
| 1201 | * |
||
| 1202 | * @return string |
||
| 1203 | * |
||
| 1204 | * @throws DBALException If not supported on this platform. |
||
| 1205 | */ |
||
| 1206 | 58620 | public function getDateSubWeeksExpression($date, $weeks) |
|
| 1210 | |||
| 1211 | /** |
||
| 1212 | * Returns the SQL to add the number of given months to a date. |
||
| 1213 | * |
||
| 1214 | * @param string $date |
||
| 1215 | * @param int $months |
||
| 1216 | * |
||
| 1217 | * @return string |
||
| 1218 | * |
||
| 1219 | * @throws DBALException If not supported on this platform. |
||
| 1220 | */ |
||
| 1221 | 58620 | public function getDateAddMonthExpression($date, $months) |
|
| 1225 | |||
| 1226 | /** |
||
| 1227 | * Returns the SQL to subtract the number of given months to a date. |
||
| 1228 | * |
||
| 1229 | * @param string $date |
||
| 1230 | * @param int $months |
||
| 1231 | * |
||
| 1232 | * @return string |
||
| 1233 | * |
||
| 1234 | * @throws DBALException If not supported on this platform. |
||
| 1235 | */ |
||
| 1236 | 58620 | public function getDateSubMonthExpression($date, $months) |
|
| 1240 | |||
| 1241 | /** |
||
| 1242 | * Returns the SQL to add the number of given quarters to a date. |
||
| 1243 | * |
||
| 1244 | * @param string $date |
||
| 1245 | * @param int $quarters |
||
| 1246 | * |
||
| 1247 | * @return string |
||
| 1248 | * |
||
| 1249 | * @throws DBALException If not supported on this platform. |
||
| 1250 | */ |
||
| 1251 | 58620 | public function getDateAddQuartersExpression($date, $quarters) |
|
| 1255 | |||
| 1256 | /** |
||
| 1257 | * Returns the SQL to subtract the number of given quarters from a date. |
||
| 1258 | * |
||
| 1259 | * @param string $date |
||
| 1260 | * @param int $quarters |
||
| 1261 | * |
||
| 1262 | * @return string |
||
| 1263 | * |
||
| 1264 | * @throws DBALException If not supported on this platform. |
||
| 1265 | */ |
||
| 1266 | 58620 | public function getDateSubQuartersExpression($date, $quarters) |
|
| 1270 | |||
| 1271 | /** |
||
| 1272 | * Returns the SQL to add the number of given years to a date. |
||
| 1273 | * |
||
| 1274 | * @param string $date |
||
| 1275 | * @param int $years |
||
| 1276 | * |
||
| 1277 | * @return string |
||
| 1278 | * |
||
| 1279 | * @throws DBALException If not supported on this platform. |
||
| 1280 | */ |
||
| 1281 | 58620 | public function getDateAddYearsExpression($date, $years) |
|
| 1285 | |||
| 1286 | /** |
||
| 1287 | * Returns the SQL to subtract the number of given years from a date. |
||
| 1288 | * |
||
| 1289 | * @param string $date |
||
| 1290 | * @param int $years |
||
| 1291 | * |
||
| 1292 | * @return string |
||
| 1293 | * |
||
| 1294 | * @throws DBALException If not supported on this platform. |
||
| 1295 | */ |
||
| 1296 | 58620 | public function getDateSubYearsExpression($date, $years) |
|
| 1300 | |||
| 1301 | /** |
||
| 1302 | * Returns the SQL for a date arithmetic expression. |
||
| 1303 | * |
||
| 1304 | * @param string $date The column or literal representing a date to perform the arithmetic operation on. |
||
| 1305 | * @param string $operator The arithmetic operator (+ or -). |
||
| 1306 | * @param int $interval The interval that shall be calculated into the date. |
||
| 1307 | * @param string $unit The unit of the interval that shall be calculated into the date. |
||
| 1308 | * One of the DATE_INTERVAL_UNIT_* constants. |
||
| 1309 | * |
||
| 1310 | * @return string |
||
| 1311 | * |
||
| 1312 | * @throws DBALException If not supported on this platform. |
||
| 1313 | */ |
||
| 1314 | protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) |
||
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Returns the SQL bit AND comparison expression. |
||
| 1321 | * |
||
| 1322 | * @param string $value1 |
||
| 1323 | * @param string $value2 |
||
| 1324 | * |
||
| 1325 | * @return string |
||
| 1326 | */ |
||
| 1327 | 58296 | public function getBitAndComparisonExpression($value1, $value2) |
|
| 1331 | |||
| 1332 | /** |
||
| 1333 | * Returns the SQL bit OR comparison expression. |
||
| 1334 | * |
||
| 1335 | * @param string $value1 |
||
| 1336 | * @param string $value2 |
||
| 1337 | * |
||
| 1338 | * @return string |
||
| 1339 | */ |
||
| 1340 | 56098 | public function getBitOrComparisonExpression($value1, $value2) |
|
| 1344 | |||
| 1345 | /** |
||
| 1346 | * Returns the FOR UPDATE expression. |
||
| 1347 | * |
||
| 1348 | * @return string |
||
| 1349 | */ |
||
| 1350 | 45668 | public function getForUpdateSQL() |
|
| 1354 | |||
| 1355 | /** |
||
| 1356 | * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. |
||
| 1357 | * |
||
| 1358 | * @param string $fromClause The FROM clause to append the hint for the given lock mode to. |
||
| 1359 | * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will |
||
| 1360 | * be appended to the FROM clause. |
||
| 1361 | * |
||
| 1362 | * @return string |
||
| 1363 | */ |
||
| 1364 | 48071 | public function appendLockHint($fromClause, $lockMode) |
|
| 1368 | |||
| 1369 | /** |
||
| 1370 | * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock. |
||
| 1371 | * |
||
| 1372 | * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database |
||
| 1373 | * vendors allow to lighten this constraint up to be a real read lock. |
||
| 1374 | * |
||
| 1375 | * @return string |
||
| 1376 | */ |
||
| 1377 | public function getReadLockSQL() |
||
| 1381 | |||
| 1382 | /** |
||
| 1383 | * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. |
||
| 1384 | * |
||
| 1385 | * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard. |
||
| 1386 | * |
||
| 1387 | * @return string |
||
| 1388 | */ |
||
| 1389 | 52878 | public function getWriteLockSQL() |
|
| 1393 | |||
| 1394 | /** |
||
| 1395 | * Returns the SQL snippet to drop an existing database. |
||
| 1396 | * |
||
| 1397 | * @param string $database The name of the database that should be dropped. |
||
| 1398 | * |
||
| 1399 | * @return string |
||
| 1400 | */ |
||
| 1401 | 46728 | public function getDropDatabaseSQL($database) |
|
| 1405 | |||
| 1406 | /** |
||
| 1407 | * Returns the SQL snippet to drop an existing table. |
||
| 1408 | * |
||
| 1409 | * @param Table|string $table |
||
| 1410 | * |
||
| 1411 | * @return string |
||
| 1412 | * |
||
| 1413 | * @throws InvalidArgumentException |
||
| 1414 | */ |
||
| 1415 | 59650 | public function getDropTableSQL($table) |
|
| 1444 | |||
| 1445 | /** |
||
| 1446 | * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. |
||
| 1447 | * |
||
| 1448 | * @param Table|string $table |
||
| 1449 | * |
||
| 1450 | * @return string |
||
| 1451 | */ |
||
| 1452 | 26425 | public function getDropTemporaryTableSQL($table) |
|
| 1456 | |||
| 1457 | /** |
||
| 1458 | * Returns the SQL to drop an index from a table. |
||
| 1459 | * |
||
| 1460 | * @param Index|string $index |
||
| 1461 | * @param Table|string $table |
||
| 1462 | * |
||
| 1463 | * @return string |
||
| 1464 | * |
||
| 1465 | * @throws InvalidArgumentException |
||
| 1466 | */ |
||
| 1467 | 46637 | public function getDropIndexSQL($index, $table = null) |
|
| 1477 | |||
| 1478 | /** |
||
| 1479 | * Returns the SQL to drop a constraint. |
||
| 1480 | * |
||
| 1481 | * @param Constraint|string $constraint |
||
| 1482 | * @param Table|string $table |
||
| 1483 | * |
||
| 1484 | * @return string |
||
| 1485 | */ |
||
| 1486 | 53825 | public function getDropConstraintSQL($constraint, $table) |
|
| 1501 | |||
| 1502 | /** |
||
| 1503 | * Returns the SQL to drop a foreign key. |
||
| 1504 | * |
||
| 1505 | * @param ForeignKeyConstraint|string $foreignKey |
||
| 1506 | * @param Table|string $table |
||
| 1507 | * |
||
| 1508 | * @return string |
||
| 1509 | */ |
||
| 1510 | 54731 | public function getDropForeignKeySQL($foreignKey, $table) |
|
| 1525 | |||
| 1526 | /** |
||
| 1527 | * Returns the SQL statement(s) to create a table with the specified name, columns and constraints |
||
| 1528 | * on this platform. |
||
| 1529 | * |
||
| 1530 | * @param int $createFlags |
||
| 1531 | * |
||
| 1532 | * @return string[] The sequence of SQL statements. |
||
| 1533 | * |
||
| 1534 | * @throws DBALException |
||
| 1535 | * @throws InvalidArgumentException |
||
| 1536 | */ |
||
| 1537 | 59920 | public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) |
|
| 1630 | |||
| 1631 | 38571 | protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string |
|
| 1641 | |||
| 1642 | /** |
||
| 1643 | * @param string $tableName |
||
| 1644 | * @param string $columnName |
||
| 1645 | * @param string|null $comment |
||
| 1646 | * |
||
| 1647 | * @return string |
||
| 1648 | */ |
||
| 1649 | 53317 | public function getCommentOnColumnSQL($tableName, $columnName, $comment) |
|
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Returns the SQL to create inline comment on a column. |
||
| 1664 | * |
||
| 1665 | * @param string $comment |
||
| 1666 | * |
||
| 1667 | * @return string |
||
| 1668 | * |
||
| 1669 | * @throws DBALException If not supported on this platform. |
||
| 1670 | */ |
||
| 1671 | 54835 | public function getInlineColumnCommentSQL($comment) |
|
| 1679 | |||
| 1680 | /** |
||
| 1681 | * Returns the SQL used to create a table. |
||
| 1682 | * |
||
| 1683 | * @param string $tableName |
||
| 1684 | * @param mixed[][] $columns |
||
| 1685 | * @param mixed[] $options |
||
| 1686 | * |
||
| 1687 | * @return string[] |
||
| 1688 | */ |
||
| 1689 | 54726 | protected function _getCreateTableSQL($tableName, array $columns, array $options = []) |
|
| 1728 | |||
| 1729 | /** |
||
| 1730 | * @return string |
||
| 1731 | */ |
||
| 1732 | 48030 | public function getCreateTemporaryTableSnippetSQL() |
|
| 1736 | |||
| 1737 | /** |
||
| 1738 | * Returns the SQL to create a sequence on this platform. |
||
| 1739 | * |
||
| 1740 | * @return string |
||
| 1741 | * |
||
| 1742 | * @throws DBALException If not supported on this platform. |
||
| 1743 | */ |
||
| 1744 | public function getCreateSequenceSQL(Sequence $sequence) |
||
| 1748 | |||
| 1749 | /** |
||
| 1750 | * Returns the SQL to change a sequence on this platform. |
||
| 1751 | * |
||
| 1752 | * @return string |
||
| 1753 | * |
||
| 1754 | * @throws DBALException If not supported on this platform. |
||
| 1755 | */ |
||
| 1756 | public function getAlterSequenceSQL(Sequence $sequence) |
||
| 1760 | |||
| 1761 | /** |
||
| 1762 | * Returns the SQL to create a constraint on a table on this platform. |
||
| 1763 | * |
||
| 1764 | * @param Table|string $table |
||
| 1765 | * |
||
| 1766 | * @return string |
||
| 1767 | * |
||
| 1768 | * @throws InvalidArgumentException |
||
| 1769 | */ |
||
| 1770 | 53286 | public function getCreateConstraintSQL(Constraint $constraint, $table) |
|
| 1802 | |||
| 1803 | /** |
||
| 1804 | * Returns the SQL to create an index on a table on this platform. |
||
| 1805 | * |
||
| 1806 | * @param Table|string $table The name of the table on which the index is to be created. |
||
| 1807 | * |
||
| 1808 | * @return string |
||
| 1809 | * |
||
| 1810 | * @throws InvalidArgumentException |
||
| 1811 | */ |
||
| 1812 | 57517 | public function getCreateIndexSQL(Index $index, $table) |
|
| 1834 | |||
| 1835 | /** |
||
| 1836 | * Adds condition for partial index. |
||
| 1837 | * |
||
| 1838 | * @return string |
||
| 1839 | */ |
||
| 1840 | 58593 | protected function getPartialIndexSQL(Index $index) |
|
| 1848 | |||
| 1849 | /** |
||
| 1850 | * Adds additional flags for index generation. |
||
| 1851 | * |
||
| 1852 | * @return string |
||
| 1853 | */ |
||
| 1854 | 56024 | protected function getCreateIndexSQLFlags(Index $index) |
|
| 1858 | |||
| 1859 | /** |
||
| 1860 | * Returns the SQL to create an unnamed primary key constraint. |
||
| 1861 | * |
||
| 1862 | * @param Table|string $table |
||
| 1863 | * |
||
| 1864 | * @return string |
||
| 1865 | */ |
||
| 1866 | 54251 | public function getCreatePrimaryKeySQL(Index $index, $table) |
|
| 1874 | |||
| 1875 | /** |
||
| 1876 | * Returns the SQL to create a named schema. |
||
| 1877 | * |
||
| 1878 | * @param string $schemaName |
||
| 1879 | * |
||
| 1880 | * @return string |
||
| 1881 | * |
||
| 1882 | * @throws DBALException If not supported on this platform. |
||
| 1883 | */ |
||
| 1884 | 52726 | public function getCreateSchemaSQL($schemaName) |
|
| 1888 | |||
| 1889 | /** |
||
| 1890 | * Quotes a string so that it can be safely used as a table or column name, |
||
| 1891 | * even if it is a reserved word of the platform. This also detects identifier |
||
| 1892 | * chains separated by dot and quotes them independently. |
||
| 1893 | * |
||
| 1894 | * NOTE: Just because you CAN use quoted identifiers doesn't mean |
||
| 1895 | * you SHOULD use them. In general, they end up causing way more |
||
| 1896 | * problems than they solve. |
||
| 1897 | * |
||
| 1898 | * @param string $str The identifier name to be quoted. |
||
| 1899 | * |
||
| 1900 | * @return string The quoted identifier string. |
||
| 1901 | */ |
||
| 1902 | 59539 | public function quoteIdentifier($str) |
|
| 1912 | |||
| 1913 | /** |
||
| 1914 | * Quotes a single identifier (no dot chain separation). |
||
| 1915 | * |
||
| 1916 | * @param string $str The identifier name to be quoted. |
||
| 1917 | * |
||
| 1918 | * @return string The quoted identifier string. |
||
| 1919 | */ |
||
| 1920 | 59369 | public function quoteSingleIdentifier($str) |
|
| 1926 | |||
| 1927 | /** |
||
| 1928 | * Returns the SQL to create a new foreign key. |
||
| 1929 | * |
||
| 1930 | * @param ForeignKeyConstraint $foreignKey The foreign key constraint. |
||
| 1931 | * @param Table|string $table The name of the table on which the foreign key is to be created. |
||
| 1932 | * |
||
| 1933 | * @return string |
||
| 1934 | */ |
||
| 1935 | 58300 | public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) |
|
| 1943 | |||
| 1944 | /** |
||
| 1945 | * Gets the SQL statements for altering an existing table. |
||
| 1946 | * |
||
| 1947 | * This method returns an array of SQL statements, since some platforms need several statements. |
||
| 1948 | * |
||
| 1949 | * @return string[] |
||
| 1950 | * |
||
| 1951 | * @throws DBALException If not supported on this platform. |
||
| 1952 | */ |
||
| 1953 | public function getAlterTableSQL(TableDiff $diff) |
||
| 1957 | |||
| 1958 | /** |
||
| 1959 | * @param mixed[] $columnSql |
||
| 1960 | * |
||
| 1961 | * @return bool |
||
| 1962 | */ |
||
| 1963 | 57407 | protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, &$columnSql) |
|
| 1980 | |||
| 1981 | /** |
||
| 1982 | * @param string[] $columnSql |
||
| 1983 | * |
||
| 1984 | * @return bool |
||
| 1985 | */ |
||
| 1986 | 56666 | protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, &$columnSql) |
|
| 2003 | |||
| 2004 | /** |
||
| 2005 | * @param string[] $columnSql |
||
| 2006 | * |
||
| 2007 | * @return bool |
||
| 2008 | */ |
||
| 2009 | 57358 | protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, &$columnSql) |
|
| 2026 | |||
| 2027 | /** |
||
| 2028 | * @param string $oldColumnName |
||
| 2029 | * @param string[] $columnSql |
||
| 2030 | * |
||
| 2031 | * @return bool |
||
| 2032 | */ |
||
| 2033 | 56572 | protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column, TableDiff $diff, &$columnSql) |
|
| 2050 | |||
| 2051 | /** |
||
| 2052 | * @param string[] $sql |
||
| 2053 | * |
||
| 2054 | * @return bool |
||
| 2055 | */ |
||
| 2056 | 57964 | protected function onSchemaAlterTable(TableDiff $diff, &$sql) |
|
| 2073 | |||
| 2074 | /** |
||
| 2075 | * @return string[] |
||
| 2076 | */ |
||
| 2077 | 57823 | protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
| 2102 | |||
| 2103 | /** |
||
| 2104 | * @return string[] |
||
| 2105 | */ |
||
| 2106 | 57823 | protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
| 2145 | |||
| 2146 | /** |
||
| 2147 | * Returns the SQL for renaming an index on a table. |
||
| 2148 | * |
||
| 2149 | * @param string $oldIndexName The name of the index to rename from. |
||
| 2150 | * @param Index $index The definition of the index to rename to. |
||
| 2151 | * @param string $tableName The table to rename the given index on. |
||
| 2152 | * |
||
| 2153 | * @return string[] The sequence of SQL statements for renaming the given index. |
||
| 2154 | */ |
||
| 2155 | 52233 | protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) |
|
| 2162 | |||
| 2163 | /** |
||
| 2164 | * Common code for alter table statement generation that updates the changed Index and Foreign Key definitions. |
||
| 2165 | * |
||
| 2166 | * @deprecated |
||
| 2167 | * |
||
| 2168 | * @return string[] |
||
| 2169 | */ |
||
| 2170 | protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
| 2174 | |||
| 2175 | /** |
||
| 2176 | * Gets declaration of a number of fields in bulk. |
||
| 2177 | * |
||
| 2178 | * @param mixed[][] $fields A multidimensional associative array. |
||
| 2179 | * The first dimension determines the field name, while the second |
||
| 2180 | * dimension is keyed with the name of the properties |
||
| 2181 | * of the field being declared as array indexes. Currently, the types |
||
| 2182 | * of supported field properties are as follows: |
||
| 2183 | * |
||
| 2184 | * length |
||
| 2185 | * Integer value that determines the maximum length of the text |
||
| 2186 | * field. If this argument is missing the field should be |
||
| 2187 | * declared to have the longest length allowed by the DBMS. |
||
| 2188 | * |
||
| 2189 | * default |
||
| 2190 | * Text value to be used as default for this field. |
||
| 2191 | * |
||
| 2192 | * notnull |
||
| 2193 | * Boolean flag that indicates whether this field is constrained |
||
| 2194 | * to not be set to null. |
||
| 2195 | * charset |
||
| 2196 | * Text value with the default CHARACTER SET for this field. |
||
| 2197 | * collation |
||
| 2198 | * Text value with the default COLLATION for this field. |
||
| 2199 | * unique |
||
| 2200 | * unique constraint |
||
| 2201 | * |
||
| 2202 | * @return string |
||
| 2203 | */ |
||
| 2204 | 59902 | public function getColumnDeclarationListSQL(array $fields) |
|
| 2214 | |||
| 2215 | /** |
||
| 2216 | * Obtains DBMS specific SQL code portion needed to declare a generic type |
||
| 2217 | * field to be used in statements like CREATE TABLE. |
||
| 2218 | * |
||
| 2219 | * @param string $name The name the field to be declared. |
||
| 2220 | * @param mixed[] $field An associative array with the name of the properties |
||
| 2221 | * of the field being declared as array indexes. Currently, the types |
||
| 2222 | * of supported field properties are as follows: |
||
| 2223 | * |
||
| 2224 | * length |
||
| 2225 | * Integer value that determines the maximum length of the text |
||
| 2226 | * field. If this argument is missing the field should be |
||
| 2227 | * declared to have the longest length allowed by the DBMS. |
||
| 2228 | * |
||
| 2229 | * default |
||
| 2230 | * Text value to be used as default for this field. |
||
| 2231 | * |
||
| 2232 | * notnull |
||
| 2233 | * Boolean flag that indicates whether this field is constrained |
||
| 2234 | * to not be set to null. |
||
| 2235 | * charset |
||
| 2236 | * Text value with the default CHARACTER SET for this field. |
||
| 2237 | * collation |
||
| 2238 | * Text value with the default COLLATION for this field. |
||
| 2239 | * unique |
||
| 2240 | * unique constraint |
||
| 2241 | * check |
||
| 2242 | * column check constraint |
||
| 2243 | * columnDefinition |
||
| 2244 | * a string that defines the complete column |
||
| 2245 | * |
||
| 2246 | * @return string DBMS specific SQL code portion that should be used to declare the column. |
||
| 2247 | */ |
||
| 2248 | 59440 | public function getColumnDeclarationSQL($name, array $field) |
|
| 2279 | |||
| 2280 | /** |
||
| 2281 | * Returns the SQL snippet that declares a floating point column of arbitrary precision. |
||
| 2282 | * |
||
| 2283 | * @param mixed[] $columnDef |
||
| 2284 | * |
||
| 2285 | * @return string |
||
| 2286 | */ |
||
| 2287 | 57153 | public function getDecimalTypeDeclarationSQL(array $columnDef) |
|
| 2296 | |||
| 2297 | /** |
||
| 2298 | * Obtains DBMS specific SQL code portion needed to set a default value |
||
| 2299 | * declaration to be used in statements like CREATE TABLE. |
||
| 2300 | * |
||
| 2301 | * @param mixed[] $field The field definition array. |
||
| 2302 | * |
||
| 2303 | * @return string DBMS specific SQL code portion needed to set a default value. |
||
| 2304 | */ |
||
| 2305 | 59981 | public function getDefaultValueDeclarationSQL($field) |
|
| 2341 | |||
| 2342 | /** |
||
| 2343 | * Obtains DBMS specific SQL code portion needed to set a CHECK constraint |
||
| 2344 | * declaration to be used in statements like CREATE TABLE. |
||
| 2345 | * |
||
| 2346 | * @param string[]|mixed[][] $definition The check definition. |
||
| 2347 | * |
||
| 2348 | * @return string DBMS specific SQL code portion needed to set a CHECK constraint. |
||
| 2349 | */ |
||
| 2350 | 55185 | public function getCheckDeclarationSQL(array $definition) |
|
| 2369 | |||
| 2370 | /** |
||
| 2371 | * Obtains DBMS specific SQL code portion needed to set a unique |
||
| 2372 | * constraint declaration to be used in statements like CREATE TABLE. |
||
| 2373 | * |
||
| 2374 | * @param string $name The name of the unique constraint. |
||
| 2375 | * @param Index $index The index definition. |
||
| 2376 | * |
||
| 2377 | * @return string DBMS specific SQL code portion needed to set a constraint. |
||
| 2378 | * |
||
| 2379 | * @throws InvalidArgumentException |
||
| 2380 | */ |
||
| 2381 | 53319 | public function getUniqueConstraintDeclarationSQL($name, Index $index) |
|
| 2394 | |||
| 2395 | /** |
||
| 2396 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2397 | * declaration to be used in statements like CREATE TABLE. |
||
| 2398 | * |
||
| 2399 | * @param string $name The name of the index. |
||
| 2400 | * @param Index $index The index definition. |
||
| 2401 | * |
||
| 2402 | * @return string DBMS specific SQL code portion needed to set an index. |
||
| 2403 | * |
||
| 2404 | * @throws InvalidArgumentException |
||
| 2405 | */ |
||
| 2406 | 55360 | public function getIndexDeclarationSQL($name, Index $index) |
|
| 2419 | |||
| 2420 | /** |
||
| 2421 | * Obtains SQL code portion needed to create a custom column, |
||
| 2422 | * e.g. when a field has the "columnDefinition" keyword. |
||
| 2423 | * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate. |
||
| 2424 | * |
||
| 2425 | * @param mixed[] $columnDef |
||
| 2426 | * |
||
| 2427 | * @return string |
||
| 2428 | */ |
||
| 2429 | 54887 | public function getCustomTypeDeclarationSQL(array $columnDef) |
|
| 2433 | |||
| 2434 | /** |
||
| 2435 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2436 | * declaration to be used in statements like CREATE TABLE. |
||
| 2437 | * |
||
| 2438 | * @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method |
||
| 2439 | */ |
||
| 2440 | 58659 | public function getIndexFieldDeclarationListSQL($columnsOrIndex) : string |
|
| 2462 | |||
| 2463 | /** |
||
| 2464 | * Returns the required SQL string that fits between CREATE ... TABLE |
||
| 2465 | * to create the table as a temporary table. |
||
| 2466 | * |
||
| 2467 | * Should be overridden in driver classes to return the correct string for the |
||
| 2468 | * specific database type. |
||
| 2469 | * |
||
| 2470 | * The default is to return the string "TEMPORARY" - this will result in a |
||
| 2471 | * SQL error for any database that does not support temporary tables, or that |
||
| 2472 | * requires a different SQL command from "CREATE TEMPORARY TABLE". |
||
| 2473 | * |
||
| 2474 | * @return string The string required to be placed between "CREATE" and "TABLE" |
||
| 2475 | * to generate a temporary table, if possible. |
||
| 2476 | */ |
||
| 2477 | public function getTemporaryTableSQL() |
||
| 2481 | |||
| 2482 | /** |
||
| 2483 | * Some vendors require temporary table names to be qualified specially. |
||
| 2484 | * |
||
| 2485 | * @param string $tableName |
||
| 2486 | * |
||
| 2487 | * @return string |
||
| 2488 | */ |
||
| 2489 | 45628 | public function getTemporaryTableName($tableName) |
|
| 2493 | |||
| 2494 | /** |
||
| 2495 | * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2496 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2497 | * |
||
| 2498 | * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2499 | * of a field declaration. |
||
| 2500 | */ |
||
| 2501 | 58503 | public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
| 2508 | |||
| 2509 | /** |
||
| 2510 | * Returns the FOREIGN KEY query section dealing with non-standard options |
||
| 2511 | * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... |
||
| 2512 | * |
||
| 2513 | * @param ForeignKeyConstraint $foreignKey The foreign key definition. |
||
| 2514 | * |
||
| 2515 | * @return string |
||
| 2516 | */ |
||
| 2517 | 58474 | public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) |
|
| 2530 | |||
| 2531 | /** |
||
| 2532 | * Returns the given referential action in uppercase if valid, otherwise throws an exception. |
||
| 2533 | * |
||
| 2534 | * @param string $action The foreign key referential action. |
||
| 2535 | * |
||
| 2536 | * @return string |
||
| 2537 | * |
||
| 2538 | * @throws InvalidArgumentException If unknown referential action given. |
||
| 2539 | */ |
||
| 2540 | 56921 | public function getForeignKeyReferentialActionSQL($action) |
|
| 2555 | |||
| 2556 | /** |
||
| 2557 | * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2558 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2559 | * |
||
| 2560 | * @return string |
||
| 2561 | * |
||
| 2562 | * @throws InvalidArgumentException |
||
| 2563 | */ |
||
| 2564 | 58467 | public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
| 2590 | |||
| 2591 | /** |
||
| 2592 | * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2593 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2594 | * |
||
| 2595 | * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2596 | * of a field declaration. |
||
| 2597 | */ |
||
| 2598 | public function getUniqueFieldDeclarationSQL() |
||
| 2602 | |||
| 2603 | /** |
||
| 2604 | * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2605 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2606 | * |
||
| 2607 | * @param string $charset The name of the charset. |
||
| 2608 | * |
||
| 2609 | * @return string DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2610 | * of a field declaration. |
||
| 2611 | */ |
||
| 2612 | public function getColumnCharsetDeclarationSQL($charset) |
||
| 2616 | |||
| 2617 | /** |
||
| 2618 | * Obtains DBMS specific SQL code portion needed to set the COLLATION |
||
| 2619 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2620 | * |
||
| 2621 | * @param string $collation The name of the collation. |
||
| 2622 | * |
||
| 2623 | * @return string DBMS specific SQL code portion needed to set the COLLATION |
||
| 2624 | * of a field declaration. |
||
| 2625 | */ |
||
| 2626 | 18523 | public function getColumnCollationDeclarationSQL($collation) |
|
| 2630 | |||
| 2631 | /** |
||
| 2632 | * Whether the platform prefers sequences for ID generation. |
||
| 2633 | * Subclasses should override this method to return TRUE if they prefer sequences. |
||
| 2634 | * |
||
| 2635 | * @return bool |
||
| 2636 | */ |
||
| 2637 | 5 | public function prefersSequences() |
|
| 2641 | |||
| 2642 | /** |
||
| 2643 | * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. |
||
| 2644 | * Subclasses should override this method to return TRUE if they prefer identity columns. |
||
| 2645 | * |
||
| 2646 | * @return bool |
||
| 2647 | */ |
||
| 2648 | 46898 | public function prefersIdentityColumns() |
|
| 2652 | |||
| 2653 | /** |
||
| 2654 | * Some platforms need the boolean values to be converted. |
||
| 2655 | * |
||
| 2656 | * The default conversion in this implementation converts to integers (false => 0, true => 1). |
||
| 2657 | * |
||
| 2658 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2659 | * |
||
| 2660 | * There are two contexts when converting booleans: Literals and Prepared Statements. |
||
| 2661 | * This method should handle the literal case |
||
| 2662 | * |
||
| 2663 | * @param mixed $item A boolean or an array of them. |
||
| 2664 | * |
||
| 2665 | * @return mixed A boolean database value or an array of them. |
||
| 2666 | */ |
||
| 2667 | 55789 | public function convertBooleans($item) |
|
| 2683 | |||
| 2684 | /** |
||
| 2685 | * Some platforms have boolean literals that needs to be correctly converted |
||
| 2686 | * |
||
| 2687 | * The default conversion tries to convert value into bool "(bool)$item" |
||
| 2688 | * |
||
| 2689 | * @param mixed $item |
||
| 2690 | * |
||
| 2691 | * @return bool|null |
||
| 2692 | */ |
||
| 2693 | 55199 | public function convertFromBoolean($item) |
|
| 2697 | |||
| 2698 | /** |
||
| 2699 | * This method should handle the prepared statements case. When there is no |
||
| 2700 | * distinction, it's OK to use the same method. |
||
| 2701 | * |
||
| 2702 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2703 | * |
||
| 2704 | * @param mixed $item A boolean or an array of them. |
||
| 2705 | * |
||
| 2706 | * @return mixed A boolean database value or an array of them. |
||
| 2707 | */ |
||
| 2708 | 50652 | public function convertBooleansToDatabaseValue($item) |
|
| 2712 | |||
| 2713 | /** |
||
| 2714 | * Returns the SQL specific for the platform to get the current date. |
||
| 2715 | * |
||
| 2716 | * @return string |
||
| 2717 | */ |
||
| 2718 | 56479 | public function getCurrentDateSQL() |
|
| 2722 | |||
| 2723 | /** |
||
| 2724 | * Returns the SQL specific for the platform to get the current time. |
||
| 2725 | * |
||
| 2726 | * @return string |
||
| 2727 | */ |
||
| 2728 | 30097 | public function getCurrentTimeSQL() |
|
| 2732 | |||
| 2733 | /** |
||
| 2734 | * Returns the SQL specific for the platform to get the current timestamp |
||
| 2735 | * |
||
| 2736 | * @return string |
||
| 2737 | */ |
||
| 2738 | 57646 | public function getCurrentTimestampSQL() |
|
| 2742 | |||
| 2743 | /** |
||
| 2744 | * Returns the SQL for a given transaction isolation level Connection constant. |
||
| 2745 | * |
||
| 2746 | * @param int $level |
||
| 2747 | * |
||
| 2748 | * @return string |
||
| 2749 | * |
||
| 2750 | * @throws InvalidArgumentException |
||
| 2751 | */ |
||
| 2752 | 51945 | protected function _getTransactionIsolationLevelSQL($level) |
|
| 2771 | |||
| 2772 | /** |
||
| 2773 | * @return string |
||
| 2774 | * |
||
| 2775 | * @throws DBALException If not supported on this platform. |
||
| 2776 | */ |
||
| 2777 | 2481 | public function getListDatabasesSQL() |
|
| 2781 | |||
| 2782 | /** |
||
| 2783 | * Returns the SQL statement for retrieving the namespaces defined in the database. |
||
| 2784 | * |
||
| 2785 | * @return string |
||
| 2786 | * |
||
| 2787 | * @throws DBALException If not supported on this platform. |
||
| 2788 | */ |
||
| 2789 | public function getListNamespacesSQL() |
||
| 2793 | |||
| 2794 | /** |
||
| 2795 | * @param string $database |
||
| 2796 | * |
||
| 2797 | * @return string |
||
| 2798 | * |
||
| 2799 | * @throws DBALException If not supported on this platform. |
||
| 2800 | */ |
||
| 2801 | public function getListSequencesSQL($database) |
||
| 2805 | |||
| 2806 | /** |
||
| 2807 | * @param string $table |
||
| 2808 | * |
||
| 2809 | * @return string |
||
| 2810 | * |
||
| 2811 | * @throws DBALException If not supported on this platform. |
||
| 2812 | */ |
||
| 2813 | public function getListTableConstraintsSQL($table) |
||
| 2817 | |||
| 2818 | /** |
||
| 2819 | * @param string $table |
||
| 2820 | * @param string|null $database |
||
| 2821 | * |
||
| 2822 | * @return string |
||
| 2823 | * |
||
| 2824 | * @throws DBALException If not supported on this platform. |
||
| 2825 | */ |
||
| 2826 | public function getListTableColumnsSQL($table, $database = null) |
||
| 2830 | |||
| 2831 | /** |
||
| 2832 | * @return string |
||
| 2833 | * |
||
| 2834 | * @throws DBALException If not supported on this platform. |
||
| 2835 | */ |
||
| 2836 | public function getListTablesSQL() |
||
| 2840 | |||
| 2841 | /** |
||
| 2842 | * @return string |
||
| 2843 | * |
||
| 2844 | * @throws DBALException If not supported on this platform. |
||
| 2845 | */ |
||
| 2846 | public function getListUsersSQL() |
||
| 2850 | |||
| 2851 | /** |
||
| 2852 | * Returns the SQL to list all views of a database or user. |
||
| 2853 | * |
||
| 2854 | * @param string $database |
||
| 2855 | * |
||
| 2856 | * @return string |
||
| 2857 | * |
||
| 2858 | * @throws DBALException If not supported on this platform. |
||
| 2859 | */ |
||
| 2860 | public function getListViewsSQL($database) |
||
| 2864 | |||
| 2865 | /** |
||
| 2866 | * Returns the list of indexes for the current database. |
||
| 2867 | * |
||
| 2868 | * The current database parameter is optional but will always be passed |
||
| 2869 | * when using the SchemaManager API and is the database the given table is in. |
||
| 2870 | * |
||
| 2871 | * Attention: Some platforms only support currentDatabase when they |
||
| 2872 | * are connected with that database. Cross-database information schema |
||
| 2873 | * requests may be impossible. |
||
| 2874 | * |
||
| 2875 | * @param string $table |
||
| 2876 | * @param string $currentDatabase |
||
| 2877 | * |
||
| 2878 | * @return string |
||
| 2879 | * |
||
| 2880 | * @throws DBALException If not supported on this platform. |
||
| 2881 | */ |
||
| 2882 | public function getListTableIndexesSQL($table, $currentDatabase = null) |
||
| 2886 | |||
| 2887 | /** |
||
| 2888 | * @param string $table |
||
| 2889 | * |
||
| 2890 | * @return string |
||
| 2891 | * |
||
| 2892 | * @throws DBALException If not supported on this platform. |
||
| 2893 | */ |
||
| 2894 | public function getListTableForeignKeysSQL($table) |
||
| 2898 | |||
| 2899 | /** |
||
| 2900 | * @param string $name |
||
| 2901 | * @param string $sql |
||
| 2902 | * |
||
| 2903 | * @return string |
||
| 2904 | * |
||
| 2905 | * @throws DBALException If not supported on this platform. |
||
| 2906 | */ |
||
| 2907 | public function getCreateViewSQL($name, $sql) |
||
| 2911 | |||
| 2912 | /** |
||
| 2913 | * @param string $name |
||
| 2914 | * |
||
| 2915 | * @return string |
||
| 2916 | * |
||
| 2917 | * @throws DBALException If not supported on this platform. |
||
| 2918 | */ |
||
| 2919 | public function getDropViewSQL($name) |
||
| 2923 | |||
| 2924 | /** |
||
| 2925 | * Returns the SQL snippet to drop an existing sequence. |
||
| 2926 | * |
||
| 2927 | * @param Sequence|string $sequence |
||
| 2928 | * |
||
| 2929 | * @return string |
||
| 2930 | * |
||
| 2931 | * @throws DBALException If not supported on this platform. |
||
| 2932 | */ |
||
| 2933 | public function getDropSequenceSQL($sequence) |
||
| 2937 | |||
| 2938 | /** |
||
| 2939 | * @param string $sequenceName |
||
| 2940 | * |
||
| 2941 | * @return string |
||
| 2942 | * |
||
| 2943 | * @throws DBALException If not supported on this platform. |
||
| 2944 | */ |
||
| 2945 | public function getSequenceNextValSQL($sequenceName) |
||
| 2949 | |||
| 2950 | /** |
||
| 2951 | * Returns the SQL to create a new database. |
||
| 2952 | * |
||
| 2953 | * @param string $database The name of the database that should be created. |
||
| 2954 | * |
||
| 2955 | * @return string |
||
| 2956 | * |
||
| 2957 | * @throws DBALException If not supported on this platform. |
||
| 2958 | */ |
||
| 2959 | 43655 | public function getCreateDatabaseSQL($database) |
|
| 2963 | |||
| 2964 | /** |
||
| 2965 | * Returns the SQL to set the transaction isolation level. |
||
| 2966 | * |
||
| 2967 | * @param int $level |
||
| 2968 | * |
||
| 2969 | * @return string |
||
| 2970 | * |
||
| 2971 | * @throws DBALException If not supported on this platform. |
||
| 2972 | */ |
||
| 2973 | public function getSetTransactionIsolationSQL($level) |
||
| 2977 | |||
| 2978 | /** |
||
| 2979 | * Obtains DBMS specific SQL to be used to create datetime fields in |
||
| 2980 | * statements like CREATE TABLE. |
||
| 2981 | * |
||
| 2982 | * @param mixed[] $fieldDeclaration |
||
| 2983 | * |
||
| 2984 | * @return string |
||
| 2985 | * |
||
| 2986 | * @throws DBALException If not supported on this platform. |
||
| 2987 | */ |
||
| 2988 | public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 2992 | |||
| 2993 | /** |
||
| 2994 | * Obtains DBMS specific SQL to be used to create datetime with timezone offset fields. |
||
| 2995 | * |
||
| 2996 | * @param mixed[] $fieldDeclaration |
||
| 2997 | * |
||
| 2998 | * @return string |
||
| 2999 | */ |
||
| 3000 | 33569 | public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
|
| 3004 | |||
| 3005 | /** |
||
| 3006 | * Obtains DBMS specific SQL to be used to create date fields in statements |
||
| 3007 | * like CREATE TABLE. |
||
| 3008 | * |
||
| 3009 | * @param mixed[] $fieldDeclaration |
||
| 3010 | * |
||
| 3011 | * @return string |
||
| 3012 | * |
||
| 3013 | * @throws DBALException If not supported on this platform. |
||
| 3014 | */ |
||
| 3015 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3019 | |||
| 3020 | /** |
||
| 3021 | * Obtains DBMS specific SQL to be used to create time fields in statements |
||
| 3022 | * like CREATE TABLE. |
||
| 3023 | * |
||
| 3024 | * @param mixed[] $fieldDeclaration |
||
| 3025 | * |
||
| 3026 | * @return string |
||
| 3027 | * |
||
| 3028 | * @throws DBALException If not supported on this platform. |
||
| 3029 | */ |
||
| 3030 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3034 | |||
| 3035 | /** |
||
| 3036 | * @param mixed[] $fieldDeclaration |
||
| 3037 | * |
||
| 3038 | * @return string |
||
| 3039 | */ |
||
| 3040 | 54280 | public function getFloatDeclarationSQL(array $fieldDeclaration) |
|
| 3044 | |||
| 3045 | /** |
||
| 3046 | * Gets the default transaction isolation level of the platform. |
||
| 3047 | * |
||
| 3048 | * @see TransactionIsolationLevel |
||
| 3049 | * |
||
| 3050 | * @return int The default isolation level. |
||
| 3051 | */ |
||
| 3052 | public function getDefaultTransactionIsolationLevel() |
||
| 3056 | |||
| 3057 | /* supports*() methods */ |
||
| 3058 | |||
| 3059 | /** |
||
| 3060 | * Whether the platform supports sequences. |
||
| 3061 | * |
||
| 3062 | * @return bool |
||
| 3063 | */ |
||
| 3064 | 36010 | public function supportsSequences() |
|
| 3068 | |||
| 3069 | /** |
||
| 3070 | * Whether the platform supports identity columns. |
||
| 3071 | * |
||
| 3072 | * Identity columns are columns that receive an auto-generated value from the |
||
| 3073 | * database on insert of a row. |
||
| 3074 | * |
||
| 3075 | * @return bool |
||
| 3076 | */ |
||
| 3077 | 3 | public function supportsIdentityColumns() |
|
| 3081 | |||
| 3082 | /** |
||
| 3083 | * Whether the platform emulates identity columns through sequences. |
||
| 3084 | * |
||
| 3085 | * Some platforms that do not support identity columns natively |
||
| 3086 | * but support sequences can emulate identity columns by using |
||
| 3087 | * sequences. |
||
| 3088 | * |
||
| 3089 | * @return bool |
||
| 3090 | */ |
||
| 3091 | 53930 | public function usesSequenceEmulatedIdentityColumns() |
|
| 3095 | |||
| 3096 | /** |
||
| 3097 | * Returns the name of the sequence for a particular identity column in a particular table. |
||
| 3098 | * |
||
| 3099 | * @see usesSequenceEmulatedIdentityColumns |
||
| 3100 | * |
||
| 3101 | * @param string $tableName The name of the table to return the sequence name for. |
||
| 3102 | * @param string $columnName The name of the identity column in the table to return the sequence name for. |
||
| 3103 | * |
||
| 3104 | * @return string |
||
| 3105 | * |
||
| 3106 | * @throws DBALException If not supported on this platform. |
||
| 3107 | */ |
||
| 3108 | 52659 | public function getIdentitySequenceName($tableName, $columnName) |
|
| 3112 | |||
| 3113 | /** |
||
| 3114 | * Whether the platform supports indexes. |
||
| 3115 | * |
||
| 3116 | * @return bool |
||
| 3117 | */ |
||
| 3118 | 4 | public function supportsIndexes() |
|
| 3122 | |||
| 3123 | /** |
||
| 3124 | * Whether the platform supports partial indexes. |
||
| 3125 | * |
||
| 3126 | * @return bool |
||
| 3127 | */ |
||
| 3128 | 57253 | public function supportsPartialIndexes() |
|
| 3132 | |||
| 3133 | /** |
||
| 3134 | * Whether the platform supports indexes with column length definitions. |
||
| 3135 | */ |
||
| 3136 | 57087 | public function supportsColumnLengthIndexes() : bool |
|
| 3140 | |||
| 3141 | /** |
||
| 3142 | * Whether the platform supports altering tables. |
||
| 3143 | * |
||
| 3144 | * @return bool |
||
| 3145 | */ |
||
| 3146 | 56553 | public function supportsAlterTable() |
|
| 3150 | |||
| 3151 | /** |
||
| 3152 | * Whether the platform supports transactions. |
||
| 3153 | * |
||
| 3154 | * @return bool |
||
| 3155 | */ |
||
| 3156 | 4 | public function supportsTransactions() |
|
| 3160 | |||
| 3161 | /** |
||
| 3162 | * Whether the platform supports savepoints. |
||
| 3163 | * |
||
| 3164 | * @return bool |
||
| 3165 | */ |
||
| 3166 | 57914 | public function supportsSavepoints() |
|
| 3170 | |||
| 3171 | /** |
||
| 3172 | * Whether the platform supports releasing savepoints. |
||
| 3173 | * |
||
| 3174 | * @return bool |
||
| 3175 | */ |
||
| 3176 | 55037 | public function supportsReleaseSavepoints() |
|
| 3180 | |||
| 3181 | /** |
||
| 3182 | * Whether the platform supports primary key constraints. |
||
| 3183 | * |
||
| 3184 | * @return bool |
||
| 3185 | */ |
||
| 3186 | 4 | public function supportsPrimaryConstraints() |
|
| 3190 | |||
| 3191 | /** |
||
| 3192 | * Whether the platform supports foreign key constraints. |
||
| 3193 | * |
||
| 3194 | * @return bool |
||
| 3195 | */ |
||
| 3196 | 58709 | public function supportsForeignKeyConstraints() |
|
| 3200 | |||
| 3201 | /** |
||
| 3202 | * Whether foreign key constraints can be dropped. |
||
| 3203 | * |
||
| 3204 | * If false, then getDropForeignKeySQL() throws exception. |
||
| 3205 | */ |
||
| 3206 | 57477 | public function supportsCreateDropForeignKeyConstraints() : bool |
|
| 3210 | |||
| 3211 | /** |
||
| 3212 | * Whether this platform supports onUpdate in foreign key constraints. |
||
| 3213 | * |
||
| 3214 | * @return bool |
||
| 3215 | */ |
||
| 3216 | 58478 | public function supportsForeignKeyOnUpdate() |
|
| 3220 | |||
| 3221 | /** |
||
| 3222 | * Whether the platform supports database schemas. |
||
| 3223 | * |
||
| 3224 | * @return bool |
||
| 3225 | */ |
||
| 3226 | 36016 | public function supportsSchemas() |
|
| 3230 | |||
| 3231 | /** |
||
| 3232 | * Whether this platform can emulate schemas. |
||
| 3233 | * |
||
| 3234 | * Platforms that either support or emulate schemas don't automatically |
||
| 3235 | * filter a schema for the namespaced elements in {@link |
||
| 3236 | * AbstractManager#createSchema}. |
||
| 3237 | * |
||
| 3238 | * @return bool |
||
| 3239 | */ |
||
| 3240 | 4 | public function canEmulateSchemas() |
|
| 3244 | |||
| 3245 | /** |
||
| 3246 | * Returns the default schema name. |
||
| 3247 | * |
||
| 3248 | * @return string |
||
| 3249 | * |
||
| 3250 | * @throws DBALException If not supported on this platform. |
||
| 3251 | */ |
||
| 3252 | public function getDefaultSchemaName() |
||
| 3256 | |||
| 3257 | /** |
||
| 3258 | * Whether this platform supports create database. |
||
| 3259 | * |
||
| 3260 | * Some databases don't allow to create and drop databases at all or only with certain tools. |
||
| 3261 | * |
||
| 3262 | * @return bool |
||
| 3263 | */ |
||
| 3264 | 54016 | public function supportsCreateDropDatabase() |
|
| 3268 | |||
| 3269 | /** |
||
| 3270 | * Whether the platform supports getting the affected rows of a recent update/delete type query. |
||
| 3271 | * |
||
| 3272 | * @return bool |
||
| 3273 | */ |
||
| 3274 | 4 | public function supportsGettingAffectedRows() |
|
| 3278 | |||
| 3279 | /** |
||
| 3280 | * Whether this platform support to add inline column comments as postfix. |
||
| 3281 | * |
||
| 3282 | * @return bool |
||
| 3283 | */ |
||
| 3284 | 56565 | public function supportsInlineColumnComments() |
|
| 3288 | |||
| 3289 | /** |
||
| 3290 | * Whether this platform support the proprietary syntax "COMMENT ON asset". |
||
| 3291 | * |
||
| 3292 | * @return bool |
||
| 3293 | */ |
||
| 3294 | 56981 | public function supportsCommentOnStatement() |
|
| 3298 | |||
| 3299 | /** |
||
| 3300 | * Does this platform have native guid type. |
||
| 3301 | * |
||
| 3302 | * @return bool |
||
| 3303 | */ |
||
| 3304 | 57811 | public function hasNativeGuidType() |
|
| 3308 | |||
| 3309 | /** |
||
| 3310 | * Does this platform have native JSON type. |
||
| 3311 | * |
||
| 3312 | * @return bool |
||
| 3313 | */ |
||
| 3314 | 57654 | public function hasNativeJsonType() |
|
| 3318 | |||
| 3319 | /** |
||
| 3320 | * @deprecated |
||
| 3321 | * |
||
| 3322 | * @return string |
||
| 3323 | * |
||
| 3324 | * @todo Remove in 3.0 |
||
| 3325 | */ |
||
| 3326 | public function getIdentityColumnNullInsertSQL() |
||
| 3330 | |||
| 3331 | /** |
||
| 3332 | * Whether this platform supports views. |
||
| 3333 | * |
||
| 3334 | * @return bool |
||
| 3335 | */ |
||
| 3336 | 56517 | public function supportsViews() |
|
| 3340 | |||
| 3341 | /** |
||
| 3342 | * Does this platform support column collation? |
||
| 3343 | * |
||
| 3344 | * @return bool |
||
| 3345 | */ |
||
| 3346 | public function supportsColumnCollation() |
||
| 3350 | |||
| 3351 | /** |
||
| 3352 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3353 | * the format of a stored datetime value of this platform. |
||
| 3354 | * |
||
| 3355 | * @return string The format string. |
||
| 3356 | */ |
||
| 3357 | 54142 | public function getDateTimeFormatString() |
|
| 3361 | |||
| 3362 | /** |
||
| 3363 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3364 | * the format of a stored datetime with timezone value of this platform. |
||
| 3365 | * |
||
| 3366 | * @return string The format string. |
||
| 3367 | */ |
||
| 3368 | 33832 | public function getDateTimeTzFormatString() |
|
| 3372 | |||
| 3373 | /** |
||
| 3374 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3375 | * the format of a stored date value of this platform. |
||
| 3376 | * |
||
| 3377 | * @return string The format string. |
||
| 3378 | */ |
||
| 3379 | 50223 | public function getDateFormatString() |
|
| 3383 | |||
| 3384 | /** |
||
| 3385 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3386 | * the format of a stored time value of this platform. |
||
| 3387 | * |
||
| 3388 | * @return string The format string. |
||
| 3389 | */ |
||
| 3390 | 45373 | public function getTimeFormatString() |
|
| 3394 | |||
| 3395 | /** |
||
| 3396 | * Adds an driver-specific LIMIT clause to the query. |
||
| 3397 | * |
||
| 3398 | * @param string $query |
||
| 3399 | * @param int|null $limit |
||
| 3400 | * @param int|null $offset |
||
| 3401 | * |
||
| 3402 | * @return string |
||
| 3403 | * |
||
| 3404 | * @throws DBALException |
||
| 3405 | */ |
||
| 3406 | 58349 | final public function modifyLimitQuery($query, $limit, $offset = null) |
|
| 3430 | |||
| 3431 | /** |
||
| 3432 | * Adds an platform-specific LIMIT clause to the query. |
||
| 3433 | * |
||
| 3434 | * @param string $query |
||
| 3435 | * @param int|null $limit |
||
| 3436 | * @param int|null $offset |
||
| 3437 | * |
||
| 3438 | * @return string |
||
| 3439 | */ |
||
| 3440 | 46807 | protected function doModifyLimitQuery($query, $limit, $offset) |
|
| 3452 | |||
| 3453 | /** |
||
| 3454 | * Whether the database platform support offsets in modify limit clauses. |
||
| 3455 | * |
||
| 3456 | * @return bool |
||
| 3457 | */ |
||
| 3458 | 57898 | public function supportsLimitOffset() |
|
| 3462 | |||
| 3463 | /** |
||
| 3464 | * Gets the character casing of a column in an SQL result set of this platform. |
||
| 3465 | * |
||
| 3466 | * @param string $column The column name for which to get the correct character casing. |
||
| 3467 | * |
||
| 3468 | * @return string The column name in the character casing used in SQL result sets. |
||
| 3469 | */ |
||
| 3470 | public function getSQLResultCasing($column) |
||
| 3474 | |||
| 3475 | /** |
||
| 3476 | * Makes any fixes to a name of a schema element (table, sequence, ...) that are required |
||
| 3477 | * by restrictions of the platform, like a maximum length. |
||
| 3478 | * |
||
| 3479 | * @param string $schemaElementName |
||
| 3480 | * |
||
| 3481 | * @return string |
||
| 3482 | */ |
||
| 3483 | public function fixSchemaElementName($schemaElementName) |
||
| 3487 | |||
| 3488 | /** |
||
| 3489 | * Maximum length of any given database identifier, like tables or column names. |
||
| 3490 | * |
||
| 3491 | * @return int |
||
| 3492 | */ |
||
| 3493 | 57643 | public function getMaxIdentifierLength() |
|
| 3497 | |||
| 3498 | /** |
||
| 3499 | * Returns the insert SQL for an empty insert statement. |
||
| 3500 | * |
||
| 3501 | * @param string $tableName |
||
| 3502 | * @param string $identifierColumnName |
||
| 3503 | * |
||
| 3504 | * @return string |
||
| 3505 | */ |
||
| 3506 | 30785 | public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) |
|
| 3510 | |||
| 3511 | /** |
||
| 3512 | * Generates a Truncate Table SQL statement for a given table. |
||
| 3513 | * |
||
| 3514 | * Cascade is not supported on many platforms but would optionally cascade the truncate by |
||
| 3515 | * following the foreign keys. |
||
| 3516 | * |
||
| 3517 | * @param string $tableName |
||
| 3518 | * @param bool $cascade |
||
| 3519 | * |
||
| 3520 | * @return string |
||
| 3521 | */ |
||
| 3522 | 54522 | public function getTruncateTableSQL($tableName, $cascade = false) |
|
| 3528 | |||
| 3529 | /** |
||
| 3530 | * This is for test reasons, many vendors have special requirements for dummy statements. |
||
| 3531 | * |
||
| 3532 | * @return string |
||
| 3533 | */ |
||
| 3534 | 59277 | public function getDummySelectSQL() |
|
| 3540 | |||
| 3541 | /** |
||
| 3542 | * Returns the SQL to create a new savepoint. |
||
| 3543 | * |
||
| 3544 | * @param string $savepoint |
||
| 3545 | * |
||
| 3546 | * @return string |
||
| 3547 | */ |
||
| 3548 | 51713 | public function createSavePoint($savepoint) |
|
| 3552 | |||
| 3553 | /** |
||
| 3554 | * Returns the SQL to release a savepoint. |
||
| 3555 | * |
||
| 3556 | * @param string $savepoint |
||
| 3557 | * |
||
| 3558 | * @return string |
||
| 3559 | */ |
||
| 3560 | 51712 | public function releaseSavePoint($savepoint) |
|
| 3564 | |||
| 3565 | /** |
||
| 3566 | * Returns the SQL to rollback a savepoint. |
||
| 3567 | * |
||
| 3568 | * @param string $savepoint |
||
| 3569 | * |
||
| 3570 | * @return string |
||
| 3571 | */ |
||
| 3572 | 51713 | public function rollbackSavePoint($savepoint) |
|
| 3576 | |||
| 3577 | /** |
||
| 3578 | * Returns the keyword list instance of this platform. |
||
| 3579 | * |
||
| 3580 | * @return KeywordList |
||
| 3581 | * |
||
| 3582 | * @throws DBALException If no keyword list is specified. |
||
| 3583 | */ |
||
| 3584 | 60621 | final public function getReservedKeywordsList() |
|
| 3602 | |||
| 3603 | /** |
||
| 3604 | * Returns the class name of the reserved keywords list. |
||
| 3605 | * |
||
| 3606 | * @return string |
||
| 3607 | * |
||
| 3608 | * @throws DBALException If not supported on this platform. |
||
| 3609 | */ |
||
| 3610 | protected function getReservedKeywordsClass() |
||
| 3614 | |||
| 3615 | /** |
||
| 3616 | * Quotes a literal string. |
||
| 3617 | * This method is NOT meant to fix SQL injections! |
||
| 3618 | * It is only meant to escape this platform's string literal |
||
| 3619 | * quote character inside the given literal string. |
||
| 3620 | * |
||
| 3621 | * @param string $str The literal string to be quoted. |
||
| 3622 | * |
||
| 3623 | * @return string The quoted literal string. |
||
| 3624 | */ |
||
| 3625 | 58375 | public function quoteStringLiteral($str) |
|
| 3631 | |||
| 3632 | /** |
||
| 3633 | * Gets the character used for string literal quoting. |
||
| 3634 | * |
||
| 3635 | * @return string |
||
| 3636 | */ |
||
| 3637 | 58393 | public function getStringLiteralQuoteCharacter() |
|
| 3641 | |||
| 3642 | /** |
||
| 3643 | * Escapes metacharacters in a string intended to be used with a LIKE |
||
| 3644 | * operator. |
||
| 3645 | * |
||
| 3646 | * @param string $inputString a literal, unquoted string |
||
| 3647 | * @param string $escapeChar should be reused by the caller in the LIKE |
||
| 3648 | * expression. |
||
| 3649 | */ |
||
| 3650 | 58359 | final public function escapeStringForLike(string $inputString, string $escapeChar) : string |
|
| 3658 | |||
| 3659 | 58359 | protected function getLikeWildcardCharacters() : string |
|
| 3663 | } |
||
| 3664 |
If you suppress an error, we recommend checking for the error condition explicitly: