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 | 71002 | public function __construct() |
|
| 156 | |||
| 157 | /** |
||
| 158 | * Sets the EventManager used by the Platform. |
||
| 159 | */ |
||
| 160 | 64180 | public function setEventManager(EventManager $eventManager) |
|
| 164 | |||
| 165 | /** |
||
| 166 | * Gets the EventManager used by the Platform. |
||
| 167 | * |
||
| 168 | * @return EventManager |
||
| 169 | */ |
||
| 170 | 61364 | public function getEventManager() |
|
| 174 | |||
| 175 | /** |
||
| 176 | * Returns the SQL snippet that declares a boolean column. |
||
| 177 | * |
||
| 178 | * @param mixed[] $columnDef |
||
| 179 | * |
||
| 180 | * @return string |
||
| 181 | */ |
||
| 182 | abstract public function getBooleanTypeDeclarationSQL(array $columnDef); |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Returns the SQL snippet that declares a 4 byte integer column. |
||
| 186 | * |
||
| 187 | * @param mixed[] $columnDef |
||
| 188 | * |
||
| 189 | * @return string |
||
| 190 | */ |
||
| 191 | abstract public function getIntegerTypeDeclarationSQL(array $columnDef); |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Returns the SQL snippet that declares an 8 byte integer column. |
||
| 195 | * |
||
| 196 | * @param mixed[] $columnDef |
||
| 197 | * |
||
| 198 | * @return string |
||
| 199 | */ |
||
| 200 | abstract public function getBigIntTypeDeclarationSQL(array $columnDef); |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Returns the SQL snippet that declares a 2 byte integer column. |
||
| 204 | * |
||
| 205 | * @param mixed[] $columnDef |
||
| 206 | * |
||
| 207 | * @return string |
||
| 208 | */ |
||
| 209 | abstract public function getSmallIntTypeDeclarationSQL(array $columnDef); |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Returns the SQL snippet that declares common properties of an integer column. |
||
| 213 | * |
||
| 214 | * @param mixed[] $columnDef |
||
| 215 | * |
||
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | abstract protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef); |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Lazy load Doctrine Type Mappings. |
||
| 222 | * |
||
| 223 | * @return void |
||
| 224 | */ |
||
| 225 | abstract protected function initializeDoctrineTypeMappings(); |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Initializes Doctrine Type Mappings with the platform defaults |
||
| 229 | * and with all additional type mappings. |
||
| 230 | * |
||
| 231 | * @return void |
||
| 232 | */ |
||
| 233 | 61444 | private function initializeAllDoctrineTypeMappings() |
|
| 243 | |||
| 244 | /** |
||
| 245 | * Returns the SQL snippet used to declare a VARCHAR column type. |
||
| 246 | * |
||
| 247 | * @param mixed[] $field |
||
| 248 | * |
||
| 249 | * @return string |
||
| 250 | */ |
||
| 251 | 63503 | public function getVarcharTypeDeclarationSQL(array $field) |
|
| 269 | |||
| 270 | /** |
||
| 271 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 272 | * |
||
| 273 | * @param mixed[] $field The column definition. |
||
| 274 | * |
||
| 275 | * @return string |
||
| 276 | */ |
||
| 277 | 59964 | public function getBinaryTypeDeclarationSQL(array $field) |
|
| 301 | |||
| 302 | /** |
||
| 303 | * Returns the SQL snippet to declare a GUID/UUID field. |
||
| 304 | * |
||
| 305 | * By default this maps directly to a CHAR(36) and only maps to more |
||
| 306 | * special datatypes when the underlying databases support this datatype. |
||
| 307 | * |
||
| 308 | * @param mixed[] $field |
||
| 309 | * |
||
| 310 | * @return string |
||
| 311 | */ |
||
| 312 | 59136 | public function getGuidTypeDeclarationSQL(array $field) |
|
| 319 | |||
| 320 | /** |
||
| 321 | * Returns the SQL snippet to declare a JSON field. |
||
| 322 | * |
||
| 323 | * By default this maps directly to a CLOB and only maps to more |
||
| 324 | * special datatypes when the underlying databases support this datatype. |
||
| 325 | * |
||
| 326 | * @param mixed[] $field |
||
| 327 | * |
||
| 328 | * @return string |
||
| 329 | */ |
||
| 330 | 57561 | public function getJsonTypeDeclarationSQL(array $field) |
|
| 334 | |||
| 335 | /** |
||
| 336 | * @param int $length |
||
| 337 | * @param bool $fixed |
||
| 338 | * |
||
| 339 | * @return string |
||
| 340 | * |
||
| 341 | * @throws DBALException If not supported on this platform. |
||
| 342 | */ |
||
| 343 | protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) |
||
| 347 | |||
| 348 | /** |
||
| 349 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 350 | * |
||
| 351 | * @param int $length The length of the column. |
||
| 352 | * @param bool $fixed Whether the column length is fixed. |
||
| 353 | * |
||
| 354 | * @return string |
||
| 355 | * |
||
| 356 | * @throws DBALException If not supported on this platform. |
||
| 357 | */ |
||
| 358 | protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) |
||
| 362 | |||
| 363 | /** |
||
| 364 | * Returns the SQL snippet used to declare a CLOB column type. |
||
| 365 | * |
||
| 366 | * @param mixed[] $field |
||
| 367 | * |
||
| 368 | * @return string |
||
| 369 | */ |
||
| 370 | abstract public function getClobTypeDeclarationSQL(array $field); |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Returns the SQL Snippet used to declare a BLOB column type. |
||
| 374 | * |
||
| 375 | * @param mixed[] $field |
||
| 376 | * |
||
| 377 | * @return string |
||
| 378 | */ |
||
| 379 | abstract public function getBlobTypeDeclarationSQL(array $field); |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Gets the name of the platform. |
||
| 383 | * |
||
| 384 | * @return string |
||
| 385 | */ |
||
| 386 | abstract public function getName(); |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Registers a doctrine type to be used in conjunction with a column type of this platform. |
||
| 390 | * |
||
| 391 | * @param string $dbType |
||
| 392 | * @param string $doctrineType |
||
| 393 | * |
||
| 394 | * @throws DBALException If the type is not found. |
||
| 395 | */ |
||
| 396 | 59331 | public function registerDoctrineTypeMapping($dbType, $doctrineType) |
|
| 417 | |||
| 418 | /** |
||
| 419 | * Gets the Doctrine type that is mapped for the given database column type. |
||
| 420 | * |
||
| 421 | * @param string $dbType |
||
| 422 | * |
||
| 423 | * @return string |
||
| 424 | * |
||
| 425 | * @throws DBALException |
||
| 426 | */ |
||
| 427 | 61476 | public function getDoctrineTypeMapping($dbType) |
|
| 441 | |||
| 442 | /** |
||
| 443 | * Checks if a database type is currently supported by this platform. |
||
| 444 | * |
||
| 445 | * @param string $dbType |
||
| 446 | * |
||
| 447 | * @return bool |
||
| 448 | */ |
||
| 449 | 58571 | public function hasDoctrineTypeMappingFor($dbType) |
|
| 459 | |||
| 460 | /** |
||
| 461 | * Initializes the Doctrine Type comments instance variable for in_array() checks. |
||
| 462 | * |
||
| 463 | * @return void |
||
| 464 | */ |
||
| 465 | 65013 | protected function initializeCommentedDoctrineTypes() |
|
| 479 | |||
| 480 | /** |
||
| 481 | * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type? |
||
| 482 | * |
||
| 483 | * @return bool |
||
| 484 | */ |
||
| 485 | 65266 | public function isCommentedDoctrineType(Type $doctrineType) |
|
| 495 | |||
| 496 | /** |
||
| 497 | * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements. |
||
| 498 | * |
||
| 499 | * @param string|Type $doctrineType |
||
| 500 | * |
||
| 501 | * @return void |
||
| 502 | */ |
||
| 503 | 56861 | public function markDoctrineTypeCommented($doctrineType) |
|
| 513 | |||
| 514 | /** |
||
| 515 | * Gets the comment to append to a column comment that helps parsing this type in reverse engineering. |
||
| 516 | * |
||
| 517 | * @return string |
||
| 518 | */ |
||
| 519 | 60525 | public function getDoctrineTypeComment(Type $doctrineType) |
|
| 523 | |||
| 524 | /** |
||
| 525 | * Gets the comment of a passed column modified by potential doctrine type comment hints. |
||
| 526 | * |
||
| 527 | * @return string|null |
||
| 528 | */ |
||
| 529 | 64332 | protected function getColumnComment(Column $column) |
|
| 539 | |||
| 540 | /** |
||
| 541 | * Gets the character used for identifier quoting. |
||
| 542 | * |
||
| 543 | * @return string |
||
| 544 | */ |
||
| 545 | 59745 | public function getIdentifierQuoteCharacter() |
|
| 549 | |||
| 550 | /** |
||
| 551 | * Gets the string portion that starts an SQL comment. |
||
| 552 | * |
||
| 553 | * @return string |
||
| 554 | */ |
||
| 555 | public function getSqlCommentStartString() |
||
| 559 | |||
| 560 | /** |
||
| 561 | * Gets the string portion that ends an SQL comment. |
||
| 562 | * |
||
| 563 | * @return string |
||
| 564 | */ |
||
| 565 | public function getSqlCommentEndString() |
||
| 569 | |||
| 570 | /** |
||
| 571 | * Gets the maximum length of a char field. |
||
| 572 | */ |
||
| 573 | 61251 | public function getCharMaxLength() : int |
|
| 577 | |||
| 578 | /** |
||
| 579 | * Gets the maximum length of a varchar field. |
||
| 580 | * |
||
| 581 | * @return int |
||
| 582 | */ |
||
| 583 | 58694 | public function getVarcharMaxLength() |
|
| 587 | |||
| 588 | /** |
||
| 589 | * Gets the default length of a varchar field. |
||
| 590 | * |
||
| 591 | * @return int |
||
| 592 | */ |
||
| 593 | 59778 | public function getVarcharDefaultLength() |
|
| 597 | |||
| 598 | /** |
||
| 599 | * Gets the maximum length of a binary field. |
||
| 600 | * |
||
| 601 | * @return int |
||
| 602 | */ |
||
| 603 | public function getBinaryMaxLength() |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Gets the default length of a binary field. |
||
| 610 | * |
||
| 611 | * @return int |
||
| 612 | */ |
||
| 613 | 57846 | public function getBinaryDefaultLength() |
|
| 617 | |||
| 618 | /** |
||
| 619 | * Gets all SQL wildcard characters of the platform. |
||
| 620 | * |
||
| 621 | * @return string[] |
||
| 622 | */ |
||
| 623 | public function getWildcards() |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Returns the regular expression operator. |
||
| 630 | * |
||
| 631 | * @return string |
||
| 632 | * |
||
| 633 | * @throws DBALException If not supported on this platform. |
||
| 634 | */ |
||
| 635 | 46510 | public function getRegexpExpression() |
|
| 639 | |||
| 640 | /** |
||
| 641 | * Returns the global unique identifier expression. |
||
| 642 | * |
||
| 643 | * @deprecated Use application-generated UUIDs instead |
||
| 644 | * |
||
| 645 | * @return string |
||
| 646 | * |
||
| 647 | * @throws DBALException If not supported on this platform. |
||
| 648 | */ |
||
| 649 | public function getGuidExpression() |
||
| 653 | |||
| 654 | /** |
||
| 655 | * Returns the SQL snippet to get the average value of a column. |
||
| 656 | * |
||
| 657 | * @param string $column The column to use. |
||
| 658 | * |
||
| 659 | * @return string Generated SQL including an AVG aggregate function. |
||
| 660 | */ |
||
| 661 | public function getAvgExpression($column) |
||
| 665 | |||
| 666 | /** |
||
| 667 | * Returns the SQL snippet to get the number of rows (without a NULL value) of a column. |
||
| 668 | * |
||
| 669 | * If a '*' is used instead of a column the number of selected rows is returned. |
||
| 670 | * |
||
| 671 | * @param string|int $column The column to use. |
||
| 672 | * |
||
| 673 | * @return string Generated SQL including a COUNT aggregate function. |
||
| 674 | */ |
||
| 675 | public function getCountExpression($column) |
||
| 679 | |||
| 680 | /** |
||
| 681 | * Returns the SQL snippet to get the highest value of a column. |
||
| 682 | * |
||
| 683 | * @param string $column The column to use. |
||
| 684 | * |
||
| 685 | * @return string Generated SQL including a MAX aggregate function. |
||
| 686 | */ |
||
| 687 | public function getMaxExpression($column) |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Returns the SQL snippet to get the lowest value of a column. |
||
| 694 | * |
||
| 695 | * @param string $column The column to use. |
||
| 696 | * |
||
| 697 | * @return string Generated SQL including a MIN aggregate function. |
||
| 698 | */ |
||
| 699 | public function getMinExpression($column) |
||
| 703 | |||
| 704 | /** |
||
| 705 | * Returns the SQL snippet to get the total sum of a column. |
||
| 706 | * |
||
| 707 | * @param string $column The column to use. |
||
| 708 | * |
||
| 709 | * @return string Generated SQL including a SUM aggregate function. |
||
| 710 | */ |
||
| 711 | public function getSumExpression($column) |
||
| 715 | |||
| 716 | // scalar functions |
||
| 717 | |||
| 718 | /** |
||
| 719 | * Returns the SQL snippet to get the md5 sum of a field. |
||
| 720 | * |
||
| 721 | * Note: Not SQL92, but common functionality. |
||
| 722 | * |
||
| 723 | * @param string $column |
||
| 724 | * |
||
| 725 | * @return string |
||
| 726 | */ |
||
| 727 | public function getMd5Expression($column) |
||
| 731 | |||
| 732 | /** |
||
| 733 | * Returns the SQL snippet to get the length of a text field. |
||
| 734 | * |
||
| 735 | * @param string $column |
||
| 736 | * |
||
| 737 | * @return string |
||
| 738 | */ |
||
| 739 | public function getLengthExpression($column) |
||
| 743 | |||
| 744 | /** |
||
| 745 | * Returns the SQL snippet to get the squared value of a column. |
||
| 746 | * |
||
| 747 | * @param string $column The column to use. |
||
| 748 | * |
||
| 749 | * @return string Generated SQL including an SQRT aggregate function. |
||
| 750 | */ |
||
| 751 | public function getSqrtExpression($column) |
||
| 755 | |||
| 756 | /** |
||
| 757 | * Returns the SQL snippet to round a numeric field to the number of decimals specified. |
||
| 758 | * |
||
| 759 | * @param string $column |
||
| 760 | * @param int $decimals |
||
| 761 | * |
||
| 762 | * @return string |
||
| 763 | */ |
||
| 764 | public function getRoundExpression($column, $decimals = 0) |
||
| 768 | |||
| 769 | /** |
||
| 770 | * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2. |
||
| 771 | * |
||
| 772 | * @param string $expression1 |
||
| 773 | * @param string $expression2 |
||
| 774 | * |
||
| 775 | * @return string |
||
| 776 | */ |
||
| 777 | public function getModExpression($expression1, $expression2) |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Returns the SQL snippet to trim a string. |
||
| 784 | * |
||
| 785 | * @param string $str The expression to apply the trim to. |
||
| 786 | * @param int $mode The position of the trim (leading/trailing/both). |
||
| 787 | * @param string|bool $char The char to trim, has to be quoted already. Defaults to space. |
||
| 788 | * |
||
| 789 | * @return string |
||
| 790 | */ |
||
| 791 | 55284 | public function getTrimExpression($str, $mode = TrimMode::UNSPECIFIED, $char = false) |
|
| 819 | |||
| 820 | /** |
||
| 821 | * Returns the SQL snippet to trim trailing space characters from the expression. |
||
| 822 | * |
||
| 823 | * @param string $str Literal string or column name. |
||
| 824 | * |
||
| 825 | * @return string |
||
| 826 | */ |
||
| 827 | 27608 | public function getRtrimExpression($str) |
|
| 831 | |||
| 832 | /** |
||
| 833 | * Returns the SQL snippet to trim leading space characters from the expression. |
||
| 834 | * |
||
| 835 | * @param string $str Literal string or column name. |
||
| 836 | * |
||
| 837 | * @return string |
||
| 838 | */ |
||
| 839 | 27608 | public function getLtrimExpression($str) |
|
| 843 | |||
| 844 | /** |
||
| 845 | * Returns the SQL snippet to change all characters from the expression to uppercase, |
||
| 846 | * according to the current character set mapping. |
||
| 847 | * |
||
| 848 | * @param string $str Literal string or column name. |
||
| 849 | * |
||
| 850 | * @return string |
||
| 851 | */ |
||
| 852 | public function getUpperExpression($str) |
||
| 856 | |||
| 857 | /** |
||
| 858 | * Returns the SQL snippet to change all characters from the expression to lowercase, |
||
| 859 | * according to the current character set mapping. |
||
| 860 | * |
||
| 861 | * @param string $str Literal string or column name. |
||
| 862 | * |
||
| 863 | * @return string |
||
| 864 | */ |
||
| 865 | public function getLowerExpression($str) |
||
| 869 | |||
| 870 | /** |
||
| 871 | * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. |
||
| 872 | * |
||
| 873 | * @param string $str Literal string. |
||
| 874 | * @param string $substr Literal string to find. |
||
| 875 | * @param int|false $startPos Position to start at, beginning of string by default. |
||
| 876 | * |
||
| 877 | * @return string |
||
| 878 | * |
||
| 879 | * @throws DBALException If not supported on this platform. |
||
| 880 | */ |
||
| 881 | public function getLocateExpression($str, $substr, $startPos = false) |
||
| 885 | |||
| 886 | /** |
||
| 887 | * Returns the SQL snippet to get the current system date. |
||
| 888 | * |
||
| 889 | * @return string |
||
| 890 | */ |
||
| 891 | public function getNowExpression() |
||
| 895 | |||
| 896 | /** |
||
| 897 | * Returns a SQL snippet to get a substring inside an SQL statement. |
||
| 898 | * |
||
| 899 | * Note: Not SQL92, but common functionality. |
||
| 900 | * |
||
| 901 | * SQLite only supports the 2 parameter variant of this function. |
||
| 902 | * |
||
| 903 | * @param string $value An sql string literal or column name/alias. |
||
| 904 | * @param int $from Where to start the substring portion. |
||
| 905 | * @param int|null $length The substring portion length. |
||
| 906 | * |
||
| 907 | * @return string |
||
| 908 | */ |
||
| 909 | public function getSubstringExpression($value, $from, $length = null) |
||
| 917 | |||
| 918 | /** |
||
| 919 | * Returns a SQL snippet to concatenate the given expressions. |
||
| 920 | * |
||
| 921 | * Accepts an arbitrary number of string parameters. Each parameter must contain an expression. |
||
| 922 | * |
||
| 923 | * @return string |
||
| 924 | */ |
||
| 925 | 46487 | public function getConcatExpression() |
|
| 929 | |||
| 930 | /** |
||
| 931 | * Returns the SQL for a logical not. |
||
| 932 | * |
||
| 933 | * Example: |
||
| 934 | * <code> |
||
| 935 | * $q = new Doctrine_Query(); |
||
| 936 | * $e = $q->expr; |
||
| 937 | * $q->select('*')->from('table') |
||
| 938 | * ->where($e->eq('id', $e->not('null')); |
||
| 939 | * </code> |
||
| 940 | * |
||
| 941 | * @param string $expression |
||
| 942 | * |
||
| 943 | * @return string The logical expression. |
||
| 944 | */ |
||
| 945 | public function getNotExpression($expression) |
||
| 949 | |||
| 950 | /** |
||
| 951 | * Returns the SQL that checks if an expression is null. |
||
| 952 | * |
||
| 953 | * @param string $expression The expression that should be compared to null. |
||
| 954 | * |
||
| 955 | * @return string The logical expression. |
||
| 956 | */ |
||
| 957 | 64072 | public function getIsNullExpression($expression) |
|
| 961 | |||
| 962 | /** |
||
| 963 | * Returns the SQL that checks if an expression is not null. |
||
| 964 | * |
||
| 965 | * @param string $expression The expression that should be compared to null. |
||
| 966 | * |
||
| 967 | * @return string The logical expression. |
||
| 968 | */ |
||
| 969 | public function getIsNotNullExpression($expression) |
||
| 973 | |||
| 974 | /** |
||
| 975 | * Returns the SQL that checks if an expression evaluates to a value between two values. |
||
| 976 | * |
||
| 977 | * The parameter $expression is checked if it is between $value1 and $value2. |
||
| 978 | * |
||
| 979 | * Note: There is a slight difference in the way BETWEEN works on some databases. |
||
| 980 | * http://www.w3schools.com/sql/sql_between.asp. If you want complete database |
||
| 981 | * independence you should avoid using between(). |
||
| 982 | * |
||
| 983 | * @param string $expression The value to compare to. |
||
| 984 | * @param string $value1 The lower value to compare with. |
||
| 985 | * @param string $value2 The higher value to compare with. |
||
| 986 | * |
||
| 987 | * @return string The logical expression. |
||
| 988 | */ |
||
| 989 | public function getBetweenExpression($expression, $value1, $value2) |
||
| 993 | |||
| 994 | /** |
||
| 995 | * Returns the SQL to get the arccosine of a value. |
||
| 996 | * |
||
| 997 | * @param string $value |
||
| 998 | * |
||
| 999 | * @return string |
||
| 1000 | */ |
||
| 1001 | public function getAcosExpression($value) |
||
| 1005 | |||
| 1006 | /** |
||
| 1007 | * Returns the SQL to get the sine of a value. |
||
| 1008 | * |
||
| 1009 | * @param string $value |
||
| 1010 | * |
||
| 1011 | * @return string |
||
| 1012 | */ |
||
| 1013 | public function getSinExpression($value) |
||
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Returns the SQL to get the PI value. |
||
| 1020 | * |
||
| 1021 | * @return string |
||
| 1022 | */ |
||
| 1023 | public function getPiExpression() |
||
| 1027 | |||
| 1028 | /** |
||
| 1029 | * Returns the SQL to get the cosine of a value. |
||
| 1030 | * |
||
| 1031 | * @param string $value |
||
| 1032 | * |
||
| 1033 | * @return string |
||
| 1034 | */ |
||
| 1035 | public function getCosExpression($value) |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * Returns the SQL to calculate the difference in days between the two passed dates. |
||
| 1042 | * |
||
| 1043 | * Computes diff = date1 - date2. |
||
| 1044 | * |
||
| 1045 | * @param string $date1 |
||
| 1046 | * @param string $date2 |
||
| 1047 | * |
||
| 1048 | * @return string |
||
| 1049 | * |
||
| 1050 | * @throws DBALException If not supported on this platform. |
||
| 1051 | */ |
||
| 1052 | public function getDateDiffExpression($date1, $date2) |
||
| 1056 | |||
| 1057 | /** |
||
| 1058 | * Returns the SQL to add the number of given seconds to a date. |
||
| 1059 | * |
||
| 1060 | * @param string $date |
||
| 1061 | * @param int $seconds |
||
| 1062 | * |
||
| 1063 | * @return string |
||
| 1064 | * |
||
| 1065 | * @throws DBALException If not supported on this platform. |
||
| 1066 | */ |
||
| 1067 | 62258 | public function getDateAddSecondsExpression($date, $seconds) |
|
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Returns the SQL to subtract the number of given seconds from a date. |
||
| 1074 | * |
||
| 1075 | * @param string $date |
||
| 1076 | * @param int $seconds |
||
| 1077 | * |
||
| 1078 | * @return string |
||
| 1079 | * |
||
| 1080 | * @throws DBALException If not supported on this platform. |
||
| 1081 | */ |
||
| 1082 | 62258 | public function getDateSubSecondsExpression($date, $seconds) |
|
| 1086 | |||
| 1087 | /** |
||
| 1088 | * Returns the SQL to add the number of given minutes to a date. |
||
| 1089 | * |
||
| 1090 | * @param string $date |
||
| 1091 | * @param int $minutes |
||
| 1092 | * |
||
| 1093 | * @return string |
||
| 1094 | * |
||
| 1095 | * @throws DBALException If not supported on this platform. |
||
| 1096 | */ |
||
| 1097 | 62258 | public function getDateAddMinutesExpression($date, $minutes) |
|
| 1101 | |||
| 1102 | /** |
||
| 1103 | * Returns the SQL to subtract the number of given minutes from a date. |
||
| 1104 | * |
||
| 1105 | * @param string $date |
||
| 1106 | * @param int $minutes |
||
| 1107 | * |
||
| 1108 | * @return string |
||
| 1109 | * |
||
| 1110 | * @throws DBALException If not supported on this platform. |
||
| 1111 | */ |
||
| 1112 | 62258 | public function getDateSubMinutesExpression($date, $minutes) |
|
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Returns the SQL to add the number of given hours to a date. |
||
| 1119 | * |
||
| 1120 | * @param string $date |
||
| 1121 | * @param int $hours |
||
| 1122 | * |
||
| 1123 | * @return string |
||
| 1124 | * |
||
| 1125 | * @throws DBALException If not supported on this platform. |
||
| 1126 | */ |
||
| 1127 | 62258 | public function getDateAddHourExpression($date, $hours) |
|
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Returns the SQL to subtract the number of given hours to a date. |
||
| 1134 | * |
||
| 1135 | * @param string $date |
||
| 1136 | * @param int $hours |
||
| 1137 | * |
||
| 1138 | * @return string |
||
| 1139 | * |
||
| 1140 | * @throws DBALException If not supported on this platform. |
||
| 1141 | */ |
||
| 1142 | 62258 | public function getDateSubHourExpression($date, $hours) |
|
| 1146 | |||
| 1147 | /** |
||
| 1148 | * Returns the SQL to add the number of given days to a date. |
||
| 1149 | * |
||
| 1150 | * @param string $date |
||
| 1151 | * @param int $days |
||
| 1152 | * |
||
| 1153 | * @return string |
||
| 1154 | * |
||
| 1155 | * @throws DBALException If not supported on this platform. |
||
| 1156 | */ |
||
| 1157 | 62262 | public function getDateAddDaysExpression($date, $days) |
|
| 1161 | |||
| 1162 | /** |
||
| 1163 | * Returns the SQL to subtract the number of given days to a date. |
||
| 1164 | * |
||
| 1165 | * @param string $date |
||
| 1166 | * @param int $days |
||
| 1167 | * |
||
| 1168 | * @return string |
||
| 1169 | * |
||
| 1170 | * @throws DBALException If not supported on this platform. |
||
| 1171 | */ |
||
| 1172 | 62258 | public function getDateSubDaysExpression($date, $days) |
|
| 1176 | |||
| 1177 | /** |
||
| 1178 | * Returns the SQL to add the number of given weeks to a date. |
||
| 1179 | * |
||
| 1180 | * @param string $date |
||
| 1181 | * @param int $weeks |
||
| 1182 | * |
||
| 1183 | * @return string |
||
| 1184 | * |
||
| 1185 | * @throws DBALException If not supported on this platform. |
||
| 1186 | */ |
||
| 1187 | 62258 | public function getDateAddWeeksExpression($date, $weeks) |
|
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Returns the SQL to subtract the number of given weeks from a date. |
||
| 1194 | * |
||
| 1195 | * @param string $date |
||
| 1196 | * @param int $weeks |
||
| 1197 | * |
||
| 1198 | * @return string |
||
| 1199 | * |
||
| 1200 | * @throws DBALException If not supported on this platform. |
||
| 1201 | */ |
||
| 1202 | 62258 | public function getDateSubWeeksExpression($date, $weeks) |
|
| 1206 | |||
| 1207 | /** |
||
| 1208 | * Returns the SQL to add the number of given months to a date. |
||
| 1209 | * |
||
| 1210 | * @param string $date |
||
| 1211 | * @param int $months |
||
| 1212 | * |
||
| 1213 | * @return string |
||
| 1214 | * |
||
| 1215 | * @throws DBALException If not supported on this platform. |
||
| 1216 | */ |
||
| 1217 | 62258 | public function getDateAddMonthExpression($date, $months) |
|
| 1221 | |||
| 1222 | /** |
||
| 1223 | * Returns the SQL to subtract the number of given months to a date. |
||
| 1224 | * |
||
| 1225 | * @param string $date |
||
| 1226 | * @param int $months |
||
| 1227 | * |
||
| 1228 | * @return string |
||
| 1229 | * |
||
| 1230 | * @throws DBALException If not supported on this platform. |
||
| 1231 | */ |
||
| 1232 | 62258 | public function getDateSubMonthExpression($date, $months) |
|
| 1236 | |||
| 1237 | /** |
||
| 1238 | * Returns the SQL to add the number of given quarters to a date. |
||
| 1239 | * |
||
| 1240 | * @param string $date |
||
| 1241 | * @param int $quarters |
||
| 1242 | * |
||
| 1243 | * @return string |
||
| 1244 | * |
||
| 1245 | * @throws DBALException If not supported on this platform. |
||
| 1246 | */ |
||
| 1247 | 62258 | public function getDateAddQuartersExpression($date, $quarters) |
|
| 1251 | |||
| 1252 | /** |
||
| 1253 | * Returns the SQL to subtract the number of given quarters from a date. |
||
| 1254 | * |
||
| 1255 | * @param string $date |
||
| 1256 | * @param int $quarters |
||
| 1257 | * |
||
| 1258 | * @return string |
||
| 1259 | * |
||
| 1260 | * @throws DBALException If not supported on this platform. |
||
| 1261 | */ |
||
| 1262 | 62258 | public function getDateSubQuartersExpression($date, $quarters) |
|
| 1266 | |||
| 1267 | /** |
||
| 1268 | * Returns the SQL to add the number of given years to a date. |
||
| 1269 | * |
||
| 1270 | * @param string $date |
||
| 1271 | * @param int $years |
||
| 1272 | * |
||
| 1273 | * @return string |
||
| 1274 | * |
||
| 1275 | * @throws DBALException If not supported on this platform. |
||
| 1276 | */ |
||
| 1277 | 62258 | public function getDateAddYearsExpression($date, $years) |
|
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Returns the SQL to subtract the number of given years from a date. |
||
| 1284 | * |
||
| 1285 | * @param string $date |
||
| 1286 | * @param int $years |
||
| 1287 | * |
||
| 1288 | * @return string |
||
| 1289 | * |
||
| 1290 | * @throws DBALException If not supported on this platform. |
||
| 1291 | */ |
||
| 1292 | 62258 | public function getDateSubYearsExpression($date, $years) |
|
| 1296 | |||
| 1297 | /** |
||
| 1298 | * Returns the SQL for a date arithmetic expression. |
||
| 1299 | * |
||
| 1300 | * @param string $date The column or literal representing a date to perform the arithmetic operation on. |
||
| 1301 | * @param string $operator The arithmetic operator (+ or -). |
||
| 1302 | * @param int $interval The interval that shall be calculated into the date. |
||
| 1303 | * @param string $unit The unit of the interval that shall be calculated into the date. |
||
| 1304 | * One of the DATE_INTERVAL_UNIT_* constants. |
||
| 1305 | * |
||
| 1306 | * @return string |
||
| 1307 | * |
||
| 1308 | * @throws DBALException If not supported on this platform. |
||
| 1309 | */ |
||
| 1310 | protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) |
||
| 1314 | |||
| 1315 | /** |
||
| 1316 | * Returns the SQL bit AND comparison expression. |
||
| 1317 | * |
||
| 1318 | * @param string $value1 |
||
| 1319 | * @param string $value2 |
||
| 1320 | * |
||
| 1321 | * @return string |
||
| 1322 | */ |
||
| 1323 | 61953 | public function getBitAndComparisonExpression($value1, $value2) |
|
| 1327 | |||
| 1328 | /** |
||
| 1329 | * Returns the SQL bit OR comparison expression. |
||
| 1330 | * |
||
| 1331 | * @param string $value1 |
||
| 1332 | * @param string $value2 |
||
| 1333 | * |
||
| 1334 | * @return string |
||
| 1335 | */ |
||
| 1336 | 59804 | public function getBitOrComparisonExpression($value1, $value2) |
|
| 1340 | |||
| 1341 | /** |
||
| 1342 | * Returns the FOR UPDATE expression. |
||
| 1343 | * |
||
| 1344 | * @return string |
||
| 1345 | */ |
||
| 1346 | 49277 | public function getForUpdateSQL() |
|
| 1350 | |||
| 1351 | /** |
||
| 1352 | * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. |
||
| 1353 | * |
||
| 1354 | * @param string $fromClause The FROM clause to append the hint for the given lock mode to. |
||
| 1355 | * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will |
||
| 1356 | * be appended to the FROM clause. |
||
| 1357 | * |
||
| 1358 | * @return string |
||
| 1359 | */ |
||
| 1360 | 51622 | public function appendLockHint($fromClause, $lockMode) |
|
| 1364 | |||
| 1365 | /** |
||
| 1366 | * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock. |
||
| 1367 | * |
||
| 1368 | * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database |
||
| 1369 | * vendors allow to lighten this constraint up to be a real read lock. |
||
| 1370 | * |
||
| 1371 | * @return string |
||
| 1372 | */ |
||
| 1373 | public function getReadLockSQL() |
||
| 1377 | |||
| 1378 | /** |
||
| 1379 | * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. |
||
| 1380 | * |
||
| 1381 | * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard. |
||
| 1382 | * |
||
| 1383 | * @return string |
||
| 1384 | */ |
||
| 1385 | 56315 | public function getWriteLockSQL() |
|
| 1389 | |||
| 1390 | /** |
||
| 1391 | * Returns the SQL snippet to drop an existing database. |
||
| 1392 | * |
||
| 1393 | * @param string $database The name of the database that should be dropped. |
||
| 1394 | * |
||
| 1395 | * @return string |
||
| 1396 | */ |
||
| 1397 | 49194 | public function getDropDatabaseSQL($database) |
|
| 1401 | |||
| 1402 | /** |
||
| 1403 | * Returns the SQL snippet to drop an existing table. |
||
| 1404 | * |
||
| 1405 | * @param Table|string $table |
||
| 1406 | * |
||
| 1407 | * @return string |
||
| 1408 | * |
||
| 1409 | * @throws InvalidArgumentException |
||
| 1410 | */ |
||
| 1411 | 63512 | public function getDropTableSQL($table) |
|
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. |
||
| 1443 | * |
||
| 1444 | * @param Table|string $table |
||
| 1445 | * |
||
| 1446 | * @return string |
||
| 1447 | */ |
||
| 1448 | 25795 | public function getDropTemporaryTableSQL($table) |
|
| 1452 | |||
| 1453 | /** |
||
| 1454 | * Returns the SQL to drop an index from a table. |
||
| 1455 | * |
||
| 1456 | * @param Index|string $index |
||
| 1457 | * @param Table|string $table |
||
| 1458 | * |
||
| 1459 | * @return string |
||
| 1460 | * |
||
| 1461 | * @throws InvalidArgumentException |
||
| 1462 | */ |
||
| 1463 | 49007 | public function getDropIndexSQL($index, $table = null) |
|
| 1473 | |||
| 1474 | /** |
||
| 1475 | * Returns the SQL to drop a constraint. |
||
| 1476 | * |
||
| 1477 | * @param Constraint|string $constraint |
||
| 1478 | * @param Table|string $table |
||
| 1479 | * |
||
| 1480 | * @return string |
||
| 1481 | */ |
||
| 1482 | 57154 | public function getDropConstraintSQL($constraint, $table) |
|
| 1497 | |||
| 1498 | /** |
||
| 1499 | * Returns the SQL to drop a foreign key. |
||
| 1500 | * |
||
| 1501 | * @param ForeignKeyConstraint|string $foreignKey |
||
| 1502 | * @param Table|string $table |
||
| 1503 | * |
||
| 1504 | * @return string |
||
| 1505 | */ |
||
| 1506 | 58243 | public function getDropForeignKeySQL($foreignKey, $table) |
|
| 1521 | |||
| 1522 | /** |
||
| 1523 | * Returns the SQL statement(s) to create a table with the specified name, columns and constraints |
||
| 1524 | * on this platform. |
||
| 1525 | * |
||
| 1526 | * @param int $createFlags |
||
| 1527 | * |
||
| 1528 | * @return string[] The sequence of SQL statements. |
||
| 1529 | * |
||
| 1530 | * @throws DBALException |
||
| 1531 | * @throws InvalidArgumentException |
||
| 1532 | */ |
||
| 1533 | 64046 | public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) |
|
| 1623 | |||
| 1624 | /** |
||
| 1625 | * @param string $tableName |
||
| 1626 | * @param string $columnName |
||
| 1627 | * @param string|null $comment |
||
| 1628 | * |
||
| 1629 | * @return string |
||
| 1630 | */ |
||
| 1631 | 56667 | public function getCommentOnColumnSQL($tableName, $columnName, $comment) |
|
| 1643 | |||
| 1644 | /** |
||
| 1645 | * Returns the SQL to create inline comment on a column. |
||
| 1646 | * |
||
| 1647 | * @param string $comment |
||
| 1648 | * |
||
| 1649 | * @return string |
||
| 1650 | * |
||
| 1651 | * @throws DBALException If not supported on this platform. |
||
| 1652 | */ |
||
| 1653 | 58425 | public function getInlineColumnCommentSQL($comment) |
|
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Returns the SQL used to create a table. |
||
| 1664 | * |
||
| 1665 | * @param string $tableName |
||
| 1666 | * @param mixed[][] $columns |
||
| 1667 | * @param mixed[] $options |
||
| 1668 | * |
||
| 1669 | * @return string[] |
||
| 1670 | */ |
||
| 1671 | 58178 | protected function _getCreateTableSQL($tableName, array $columns, array $options = []) |
|
| 1709 | |||
| 1710 | /** |
||
| 1711 | * @return string |
||
| 1712 | */ |
||
| 1713 | 51575 | public function getCreateTemporaryTableSnippetSQL() |
|
| 1717 | |||
| 1718 | /** |
||
| 1719 | * Returns the SQL to create a sequence on this platform. |
||
| 1720 | * |
||
| 1721 | * @return string |
||
| 1722 | * |
||
| 1723 | * @throws DBALException If not supported on this platform. |
||
| 1724 | */ |
||
| 1725 | public function getCreateSequenceSQL(Sequence $sequence) |
||
| 1729 | |||
| 1730 | /** |
||
| 1731 | * Returns the SQL to change a sequence on this platform. |
||
| 1732 | * |
||
| 1733 | * @return string |
||
| 1734 | * |
||
| 1735 | * @throws DBALException If not supported on this platform. |
||
| 1736 | */ |
||
| 1737 | public function getAlterSequenceSQL(Sequence $sequence) |
||
| 1741 | |||
| 1742 | /** |
||
| 1743 | * Returns the SQL to create a constraint on a table on this platform. |
||
| 1744 | * |
||
| 1745 | * @param Table|string $table |
||
| 1746 | * |
||
| 1747 | * @return string |
||
| 1748 | * |
||
| 1749 | * @throws InvalidArgumentException |
||
| 1750 | */ |
||
| 1751 | 56651 | public function getCreateConstraintSQL(Constraint $constraint, $table) |
|
| 1782 | |||
| 1783 | /** |
||
| 1784 | * Returns the SQL to create an index on a table on this platform. |
||
| 1785 | * |
||
| 1786 | * @param Table|string $table The name of the table on which the index is to be created. |
||
| 1787 | * |
||
| 1788 | * @return string |
||
| 1789 | * |
||
| 1790 | * @throws InvalidArgumentException |
||
| 1791 | */ |
||
| 1792 | 61061 | public function getCreateIndexSQL(Index $index, $table) |
|
| 1813 | |||
| 1814 | /** |
||
| 1815 | * Adds condition for partial index. |
||
| 1816 | * |
||
| 1817 | * @return string |
||
| 1818 | */ |
||
| 1819 | 62384 | protected function getPartialIndexSQL(Index $index) |
|
| 1827 | |||
| 1828 | /** |
||
| 1829 | * Adds additional flags for index generation. |
||
| 1830 | * |
||
| 1831 | * @return string |
||
| 1832 | */ |
||
| 1833 | 59348 | protected function getCreateIndexSQLFlags(Index $index) |
|
| 1837 | |||
| 1838 | /** |
||
| 1839 | * Returns the SQL to create an unnamed primary key constraint. |
||
| 1840 | * |
||
| 1841 | * @param Table|string $table |
||
| 1842 | * |
||
| 1843 | * @return string |
||
| 1844 | */ |
||
| 1845 | 57559 | public function getCreatePrimaryKeySQL(Index $index, $table) |
|
| 1853 | |||
| 1854 | /** |
||
| 1855 | * Returns the SQL to create a named schema. |
||
| 1856 | * |
||
| 1857 | * @param string $schemaName |
||
| 1858 | * |
||
| 1859 | * @return string |
||
| 1860 | * |
||
| 1861 | * @throws DBALException If not supported on this platform. |
||
| 1862 | */ |
||
| 1863 | 55995 | public function getCreateSchemaSQL($schemaName) |
|
| 1867 | |||
| 1868 | /** |
||
| 1869 | * Quotes a string so that it can be safely used as a table or column name, |
||
| 1870 | * even if it is a reserved word of the platform. This also detects identifier |
||
| 1871 | * chains separated by dot and quotes them independently. |
||
| 1872 | * |
||
| 1873 | * NOTE: Just because you CAN use quoted identifiers doesn't mean |
||
| 1874 | * you SHOULD use them. In general, they end up causing way more |
||
| 1875 | * problems than they solve. |
||
| 1876 | * |
||
| 1877 | * @param string $str The identifier name to be quoted. |
||
| 1878 | * |
||
| 1879 | * @return string The quoted identifier string. |
||
| 1880 | */ |
||
| 1881 | 63681 | public function quoteIdentifier($str) |
|
| 1891 | |||
| 1892 | /** |
||
| 1893 | * Quotes a single identifier (no dot chain separation). |
||
| 1894 | * |
||
| 1895 | * @param string $str The identifier name to be quoted. |
||
| 1896 | * |
||
| 1897 | * @return string The quoted identifier string. |
||
| 1898 | */ |
||
| 1899 | 63254 | public function quoteSingleIdentifier($str) |
|
| 1905 | |||
| 1906 | /** |
||
| 1907 | * Returns the SQL to create a new foreign key. |
||
| 1908 | * |
||
| 1909 | * @param ForeignKeyConstraint $foreignKey The foreign key constraint. |
||
| 1910 | * @param Table|string $table The name of the table on which the foreign key is to be created. |
||
| 1911 | * |
||
| 1912 | * @return string |
||
| 1913 | */ |
||
| 1914 | 62019 | public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) |
|
| 1922 | |||
| 1923 | /** |
||
| 1924 | * Gets the SQL statements for altering an existing table. |
||
| 1925 | * |
||
| 1926 | * This method returns an array of SQL statements, since some platforms need several statements. |
||
| 1927 | * |
||
| 1928 | * @return string[] |
||
| 1929 | * |
||
| 1930 | * @throws DBALException If not supported on this platform. |
||
| 1931 | */ |
||
| 1932 | public function getAlterTableSQL(TableDiff $diff) |
||
| 1936 | |||
| 1937 | /** |
||
| 1938 | * @param mixed[] $columnSql |
||
| 1939 | * |
||
| 1940 | * @return bool |
||
| 1941 | */ |
||
| 1942 | 61072 | protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, &$columnSql) |
|
| 1959 | |||
| 1960 | /** |
||
| 1961 | * @param string[] $columnSql |
||
| 1962 | * |
||
| 1963 | * @return bool |
||
| 1964 | */ |
||
| 1965 | 60171 | protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, &$columnSql) |
|
| 1982 | |||
| 1983 | /** |
||
| 1984 | * @param string[] $columnSql |
||
| 1985 | * |
||
| 1986 | * @return bool |
||
| 1987 | */ |
||
| 1988 | 61035 | protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, &$columnSql) |
|
| 2005 | |||
| 2006 | /** |
||
| 2007 | * @param string $oldColumnName |
||
| 2008 | * @param string[] $columnSql |
||
| 2009 | * |
||
| 2010 | * @return bool |
||
| 2011 | */ |
||
| 2012 | 59942 | protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column, TableDiff $diff, &$columnSql) |
|
| 2029 | |||
| 2030 | /** |
||
| 2031 | * @param string[] $sql |
||
| 2032 | * |
||
| 2033 | * @return bool |
||
| 2034 | */ |
||
| 2035 | 61890 | protected function onSchemaAlterTable(TableDiff $diff, &$sql) |
|
| 2052 | |||
| 2053 | /** |
||
| 2054 | * @return string[] |
||
| 2055 | */ |
||
| 2056 | 61747 | protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
| 2079 | |||
| 2080 | /** |
||
| 2081 | * @return string[] |
||
| 2082 | */ |
||
| 2083 | 61747 | protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
| 2122 | |||
| 2123 | /** |
||
| 2124 | * Returns the SQL for renaming an index on a table. |
||
| 2125 | * |
||
| 2126 | * @param string $oldIndexName The name of the index to rename from. |
||
| 2127 | * @param Index $index The definition of the index to rename to. |
||
| 2128 | * @param string $tableName The table to rename the given index on. |
||
| 2129 | * |
||
| 2130 | * @return string[] The sequence of SQL statements for renaming the given index. |
||
| 2131 | */ |
||
| 2132 | 55822 | protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) |
|
| 2139 | |||
| 2140 | /** |
||
| 2141 | * Common code for alter table statement generation that updates the changed Index and Foreign Key definitions. |
||
| 2142 | * |
||
| 2143 | * @deprecated |
||
| 2144 | * |
||
| 2145 | * @return string[] |
||
| 2146 | */ |
||
| 2147 | protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
| 2151 | |||
| 2152 | /** |
||
| 2153 | * Gets declaration of a number of fields in bulk. |
||
| 2154 | * |
||
| 2155 | * @param mixed[][] $fields A multidimensional associative array. |
||
| 2156 | * The first dimension determines the field name, while the second |
||
| 2157 | * dimension is keyed with the name of the properties |
||
| 2158 | * of the field being declared as array indexes. Currently, the types |
||
| 2159 | * of supported field properties are as follows: |
||
| 2160 | * |
||
| 2161 | * length |
||
| 2162 | * Integer value that determines the maximum length of the text |
||
| 2163 | * field. If this argument is missing the field should be |
||
| 2164 | * declared to have the longest length allowed by the DBMS. |
||
| 2165 | * |
||
| 2166 | * default |
||
| 2167 | * Text value to be used as default for this field. |
||
| 2168 | * |
||
| 2169 | * notnull |
||
| 2170 | * Boolean flag that indicates whether this field is constrained |
||
| 2171 | * to not be set to null. |
||
| 2172 | * charset |
||
| 2173 | * Text value with the default CHARACTER SET for this field. |
||
| 2174 | * collation |
||
| 2175 | * Text value with the default COLLATION for this field. |
||
| 2176 | * unique |
||
| 2177 | * unique constraint |
||
| 2178 | * |
||
| 2179 | * @return string |
||
| 2180 | */ |
||
| 2181 | 64010 | public function getColumnDeclarationListSQL(array $fields) |
|
| 2191 | |||
| 2192 | /** |
||
| 2193 | * Obtains DBMS specific SQL code portion needed to declare a generic type |
||
| 2194 | * field to be used in statements like CREATE TABLE. |
||
| 2195 | * |
||
| 2196 | * @param string $name The name the field to be declared. |
||
| 2197 | * @param mixed[] $field An associative array with the name of the properties |
||
| 2198 | * of the field being declared as array indexes. Currently, the types |
||
| 2199 | * of supported field properties are as follows: |
||
| 2200 | * |
||
| 2201 | * length |
||
| 2202 | * Integer value that determines the maximum length of the text |
||
| 2203 | * field. If this argument is missing the field should be |
||
| 2204 | * declared to have the longest length allowed by the DBMS. |
||
| 2205 | * |
||
| 2206 | * default |
||
| 2207 | * Text value to be used as default for this field. |
||
| 2208 | * |
||
| 2209 | * notnull |
||
| 2210 | * Boolean flag that indicates whether this field is constrained |
||
| 2211 | * to not be set to null. |
||
| 2212 | * charset |
||
| 2213 | * Text value with the default CHARACTER SET for this field. |
||
| 2214 | * collation |
||
| 2215 | * Text value with the default COLLATION for this field. |
||
| 2216 | * unique |
||
| 2217 | * unique constraint |
||
| 2218 | * check |
||
| 2219 | * column check constraint |
||
| 2220 | * columnDefinition |
||
| 2221 | * a string that defines the complete column |
||
| 2222 | * |
||
| 2223 | * @return string DBMS specific SQL code portion that should be used to declare the column. |
||
| 2224 | */ |
||
| 2225 | 63477 | public function getColumnDeclarationSQL($name, array $field) |
|
| 2256 | |||
| 2257 | /** |
||
| 2258 | * Returns the SQL snippet that declares a floating point column of arbitrary precision. |
||
| 2259 | * |
||
| 2260 | * @param mixed[] $columnDef |
||
| 2261 | * |
||
| 2262 | * @return string |
||
| 2263 | */ |
||
| 2264 | 60754 | public function getDecimalTypeDeclarationSQL(array $columnDef) |
|
| 2273 | |||
| 2274 | /** |
||
| 2275 | * Obtains DBMS specific SQL code portion needed to set a default value |
||
| 2276 | * declaration to be used in statements like CREATE TABLE. |
||
| 2277 | * |
||
| 2278 | * @param mixed[] $field The field definition array. |
||
| 2279 | * |
||
| 2280 | * @return string DBMS specific SQL code portion needed to set a default value. |
||
| 2281 | */ |
||
| 2282 | 64227 | public function getDefaultValueDeclarationSQL($field) |
|
| 2318 | |||
| 2319 | /** |
||
| 2320 | * Obtains DBMS specific SQL code portion needed to set a CHECK constraint |
||
| 2321 | * declaration to be used in statements like CREATE TABLE. |
||
| 2322 | * |
||
| 2323 | * @param string[]|mixed[][] $definition The check definition. |
||
| 2324 | * |
||
| 2325 | * @return string DBMS specific SQL code portion needed to set a CHECK constraint. |
||
| 2326 | */ |
||
| 2327 | 58725 | public function getCheckDeclarationSQL(array $definition) |
|
| 2346 | |||
| 2347 | /** |
||
| 2348 | * Obtains DBMS specific SQL code portion needed to set a unique |
||
| 2349 | * constraint declaration to be used in statements like CREATE TABLE. |
||
| 2350 | * |
||
| 2351 | * @param string $name The name of the unique constraint. |
||
| 2352 | * @param Index $index The index definition. |
||
| 2353 | * |
||
| 2354 | * @return string DBMS specific SQL code portion needed to set a constraint. |
||
| 2355 | * |
||
| 2356 | * @throws InvalidArgumentException |
||
| 2357 | */ |
||
| 2358 | 56681 | public function getUniqueConstraintDeclarationSQL($name, Index $index) |
|
| 2371 | |||
| 2372 | /** |
||
| 2373 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2374 | * declaration to be used in statements like CREATE TABLE. |
||
| 2375 | * |
||
| 2376 | * @param string $name The name of the index. |
||
| 2377 | * @param Index $index The index definition. |
||
| 2378 | * |
||
| 2379 | * @return string DBMS specific SQL code portion needed to set an index. |
||
| 2380 | * |
||
| 2381 | * @throws InvalidArgumentException |
||
| 2382 | */ |
||
| 2383 | 59138 | public function getIndexDeclarationSQL($name, Index $index) |
|
| 2396 | |||
| 2397 | /** |
||
| 2398 | * Obtains SQL code portion needed to create a custom column, |
||
| 2399 | * e.g. when a field has the "columnDefinition" keyword. |
||
| 2400 | * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate. |
||
| 2401 | * |
||
| 2402 | * @param mixed[] $columnDef |
||
| 2403 | * |
||
| 2404 | * @return string |
||
| 2405 | */ |
||
| 2406 | 58371 | public function getCustomTypeDeclarationSQL(array $columnDef) |
|
| 2410 | |||
| 2411 | /** |
||
| 2412 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2413 | * declaration to be used in statements like CREATE TABLE. |
||
| 2414 | * |
||
| 2415 | * @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method |
||
| 2416 | */ |
||
| 2417 | 62524 | public function getIndexFieldDeclarationListSQL($columnsOrIndex) : string |
|
| 2439 | |||
| 2440 | /** |
||
| 2441 | * Returns the required SQL string that fits between CREATE ... TABLE |
||
| 2442 | * to create the table as a temporary table. |
||
| 2443 | * |
||
| 2444 | * Should be overridden in driver classes to return the correct string for the |
||
| 2445 | * specific database type. |
||
| 2446 | * |
||
| 2447 | * The default is to return the string "TEMPORARY" - this will result in a |
||
| 2448 | * SQL error for any database that does not support temporary tables, or that |
||
| 2449 | * requires a different SQL command from "CREATE TEMPORARY TABLE". |
||
| 2450 | * |
||
| 2451 | * @return string The string required to be placed between "CREATE" and "TABLE" |
||
| 2452 | * to generate a temporary table, if possible. |
||
| 2453 | */ |
||
| 2454 | public function getTemporaryTableSQL() |
||
| 2458 | |||
| 2459 | /** |
||
| 2460 | * Some vendors require temporary table names to be qualified specially. |
||
| 2461 | * |
||
| 2462 | * @param string $tableName |
||
| 2463 | * |
||
| 2464 | * @return string |
||
| 2465 | */ |
||
| 2466 | 49231 | public function getTemporaryTableName($tableName) |
|
| 2470 | |||
| 2471 | /** |
||
| 2472 | * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2473 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2474 | * |
||
| 2475 | * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2476 | * of a field declaration. |
||
| 2477 | */ |
||
| 2478 | 62169 | public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
| 2485 | |||
| 2486 | /** |
||
| 2487 | * Returns the FOREIGN KEY query section dealing with non-standard options |
||
| 2488 | * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... |
||
| 2489 | * |
||
| 2490 | * @param ForeignKeyConstraint $foreignKey The foreign key definition. |
||
| 2491 | * |
||
| 2492 | * @return string |
||
| 2493 | */ |
||
| 2494 | 62113 | public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) |
|
| 2506 | |||
| 2507 | /** |
||
| 2508 | * Returns the given referential action in uppercase if valid, otherwise throws an exception. |
||
| 2509 | * |
||
| 2510 | * @param string $action The foreign key referential action. |
||
| 2511 | * |
||
| 2512 | * @return string |
||
| 2513 | * |
||
| 2514 | * @throws InvalidArgumentException If unknown referential action given. |
||
| 2515 | */ |
||
| 2516 | 60356 | public function getForeignKeyReferentialActionSQL($action) |
|
| 2530 | |||
| 2531 | /** |
||
| 2532 | * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2533 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2534 | * |
||
| 2535 | * @return string |
||
| 2536 | * |
||
| 2537 | * @throws InvalidArgumentException |
||
| 2538 | */ |
||
| 2539 | 62089 | public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
| 2562 | |||
| 2563 | /** |
||
| 2564 | * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2565 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2566 | * |
||
| 2567 | * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2568 | * of a field declaration. |
||
| 2569 | */ |
||
| 2570 | public function getUniqueFieldDeclarationSQL() |
||
| 2574 | |||
| 2575 | /** |
||
| 2576 | * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2577 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2578 | * |
||
| 2579 | * @param string $charset The name of the charset. |
||
| 2580 | * |
||
| 2581 | * @return string DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2582 | * of a field declaration. |
||
| 2583 | */ |
||
| 2584 | public function getColumnCharsetDeclarationSQL($charset) |
||
| 2588 | |||
| 2589 | /** |
||
| 2590 | * Obtains DBMS specific SQL code portion needed to set the COLLATION |
||
| 2591 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2592 | * |
||
| 2593 | * @param string $collation The name of the collation. |
||
| 2594 | * |
||
| 2595 | * @return string DBMS specific SQL code portion needed to set the COLLATION |
||
| 2596 | * of a field declaration. |
||
| 2597 | */ |
||
| 2598 | 58547 | public function getColumnCollationDeclarationSQL($collation) |
|
| 2602 | |||
| 2603 | /** |
||
| 2604 | * Whether the platform prefers sequences for ID generation. |
||
| 2605 | * Subclasses should override this method to return TRUE if they prefer sequences. |
||
| 2606 | * |
||
| 2607 | * @return bool |
||
| 2608 | */ |
||
| 2609 | 10 | public function prefersSequences() |
|
| 2613 | |||
| 2614 | /** |
||
| 2615 | * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. |
||
| 2616 | * Subclasses should override this method to return TRUE if they prefer identity columns. |
||
| 2617 | * |
||
| 2618 | * @return bool |
||
| 2619 | */ |
||
| 2620 | 49553 | public function prefersIdentityColumns() |
|
| 2624 | |||
| 2625 | /** |
||
| 2626 | * Some platforms need the boolean values to be converted. |
||
| 2627 | * |
||
| 2628 | * The default conversion in this implementation converts to integers (false => 0, true => 1). |
||
| 2629 | * |
||
| 2630 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2631 | * |
||
| 2632 | * There are two contexts when converting booleans: Literals and Prepared Statements. |
||
| 2633 | * This method should handle the literal case |
||
| 2634 | * |
||
| 2635 | * @param mixed $item A boolean or an array of them. |
||
| 2636 | * |
||
| 2637 | * @return mixed A boolean database value or an array of them. |
||
| 2638 | */ |
||
| 2639 | 59400 | public function convertBooleans($item) |
|
| 2655 | |||
| 2656 | /** |
||
| 2657 | * Some platforms have boolean literals that needs to be correctly converted |
||
| 2658 | * |
||
| 2659 | * The default conversion tries to convert value into bool "(bool)$item" |
||
| 2660 | * |
||
| 2661 | * @param mixed $item |
||
| 2662 | * |
||
| 2663 | * @return bool|null |
||
| 2664 | */ |
||
| 2665 | 58615 | public function convertFromBoolean($item) |
|
| 2669 | |||
| 2670 | /** |
||
| 2671 | * This method should handle the prepared statements case. When there is no |
||
| 2672 | * distinction, it's OK to use the same method. |
||
| 2673 | * |
||
| 2674 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2675 | * |
||
| 2676 | * @param mixed $item A boolean or an array of them. |
||
| 2677 | * |
||
| 2678 | * @return mixed A boolean database value or an array of them. |
||
| 2679 | */ |
||
| 2680 | 54168 | public function convertBooleansToDatabaseValue($item) |
|
| 2684 | |||
| 2685 | /** |
||
| 2686 | * Returns the SQL specific for the platform to get the current date. |
||
| 2687 | * |
||
| 2688 | * @return string |
||
| 2689 | */ |
||
| 2690 | 59949 | public function getCurrentDateSQL() |
|
| 2694 | |||
| 2695 | /** |
||
| 2696 | * Returns the SQL specific for the platform to get the current time. |
||
| 2697 | * |
||
| 2698 | * @return string |
||
| 2699 | */ |
||
| 2700 | 29345 | public function getCurrentTimeSQL() |
|
| 2704 | |||
| 2705 | /** |
||
| 2706 | * Returns the SQL specific for the platform to get the current timestamp |
||
| 2707 | * |
||
| 2708 | * @return string |
||
| 2709 | */ |
||
| 2710 | 61194 | public function getCurrentTimestampSQL() |
|
| 2714 | |||
| 2715 | /** |
||
| 2716 | * Returns the SQL for a given transaction isolation level Connection constant. |
||
| 2717 | * |
||
| 2718 | * @param int $level |
||
| 2719 | * |
||
| 2720 | * @return string |
||
| 2721 | * |
||
| 2722 | * @throws InvalidArgumentException |
||
| 2723 | */ |
||
| 2724 | 55147 | protected function _getTransactionIsolationLevelSQL($level) |
|
| 2739 | |||
| 2740 | /** |
||
| 2741 | * @return string |
||
| 2742 | * |
||
| 2743 | * @throws DBALException If not supported on this platform. |
||
| 2744 | */ |
||
| 2745 | 2413 | public function getListDatabasesSQL() |
|
| 2749 | |||
| 2750 | /** |
||
| 2751 | * Returns the SQL statement for retrieving the namespaces defined in the database. |
||
| 2752 | * |
||
| 2753 | * @return string |
||
| 2754 | * |
||
| 2755 | * @throws DBALException If not supported on this platform. |
||
| 2756 | */ |
||
| 2757 | public function getListNamespacesSQL() |
||
| 2761 | |||
| 2762 | /** |
||
| 2763 | * @param string $database |
||
| 2764 | * |
||
| 2765 | * @return string |
||
| 2766 | * |
||
| 2767 | * @throws DBALException If not supported on this platform. |
||
| 2768 | */ |
||
| 2769 | public function getListSequencesSQL($database) |
||
| 2773 | |||
| 2774 | /** |
||
| 2775 | * @param string $table |
||
| 2776 | * |
||
| 2777 | * @return string |
||
| 2778 | * |
||
| 2779 | * @throws DBALException If not supported on this platform. |
||
| 2780 | */ |
||
| 2781 | public function getListTableConstraintsSQL($table) |
||
| 2785 | |||
| 2786 | /** |
||
| 2787 | * @param string $table |
||
| 2788 | * @param string|null $database |
||
| 2789 | * |
||
| 2790 | * @return string |
||
| 2791 | * |
||
| 2792 | * @throws DBALException If not supported on this platform. |
||
| 2793 | */ |
||
| 2794 | public function getListTableColumnsSQL($table, $database = null) |
||
| 2798 | |||
| 2799 | /** |
||
| 2800 | * @return string |
||
| 2801 | * |
||
| 2802 | * @throws DBALException If not supported on this platform. |
||
| 2803 | */ |
||
| 2804 | public function getListTablesSQL() |
||
| 2808 | |||
| 2809 | /** |
||
| 2810 | * @return string |
||
| 2811 | * |
||
| 2812 | * @throws DBALException If not supported on this platform. |
||
| 2813 | */ |
||
| 2814 | public function getListUsersSQL() |
||
| 2818 | |||
| 2819 | /** |
||
| 2820 | * Returns the SQL to list all views of a database or user. |
||
| 2821 | * |
||
| 2822 | * @param string $database |
||
| 2823 | * |
||
| 2824 | * @return string |
||
| 2825 | * |
||
| 2826 | * @throws DBALException If not supported on this platform. |
||
| 2827 | */ |
||
| 2828 | public function getListViewsSQL($database) |
||
| 2832 | |||
| 2833 | /** |
||
| 2834 | * Returns the list of indexes for the current database. |
||
| 2835 | * |
||
| 2836 | * The current database parameter is optional but will always be passed |
||
| 2837 | * when using the SchemaManager API and is the database the given table is in. |
||
| 2838 | * |
||
| 2839 | * Attention: Some platforms only support currentDatabase when they |
||
| 2840 | * are connected with that database. Cross-database information schema |
||
| 2841 | * requests may be impossible. |
||
| 2842 | * |
||
| 2843 | * @param string $table |
||
| 2844 | * @param string $currentDatabase |
||
| 2845 | * |
||
| 2846 | * @return string |
||
| 2847 | * |
||
| 2848 | * @throws DBALException If not supported on this platform. |
||
| 2849 | */ |
||
| 2850 | public function getListTableIndexesSQL($table, $currentDatabase = null) |
||
| 2854 | |||
| 2855 | /** |
||
| 2856 | * @param string $table |
||
| 2857 | * |
||
| 2858 | * @return string |
||
| 2859 | * |
||
| 2860 | * @throws DBALException If not supported on this platform. |
||
| 2861 | */ |
||
| 2862 | public function getListTableForeignKeysSQL($table) |
||
| 2866 | |||
| 2867 | /** |
||
| 2868 | * @param string $name |
||
| 2869 | * @param string $sql |
||
| 2870 | * |
||
| 2871 | * @return string |
||
| 2872 | * |
||
| 2873 | * @throws DBALException If not supported on this platform. |
||
| 2874 | */ |
||
| 2875 | public function getCreateViewSQL($name, $sql) |
||
| 2879 | |||
| 2880 | /** |
||
| 2881 | * @param string $name |
||
| 2882 | * |
||
| 2883 | * @return string |
||
| 2884 | * |
||
| 2885 | * @throws DBALException If not supported on this platform. |
||
| 2886 | */ |
||
| 2887 | public function getDropViewSQL($name) |
||
| 2891 | |||
| 2892 | /** |
||
| 2893 | * Returns the SQL snippet to drop an existing sequence. |
||
| 2894 | * |
||
| 2895 | * @param Sequence|string $sequence |
||
| 2896 | * |
||
| 2897 | * @return string |
||
| 2898 | * |
||
| 2899 | * @throws DBALException If not supported on this platform. |
||
| 2900 | */ |
||
| 2901 | public function getDropSequenceSQL($sequence) |
||
| 2905 | |||
| 2906 | /** |
||
| 2907 | * @param string $sequenceName |
||
| 2908 | * |
||
| 2909 | * @return string |
||
| 2910 | * |
||
| 2911 | * @throws DBALException If not supported on this platform. |
||
| 2912 | */ |
||
| 2913 | public function getSequenceNextValSQL($sequenceName) |
||
| 2917 | |||
| 2918 | /** |
||
| 2919 | * Returns the SQL to create a new database. |
||
| 2920 | * |
||
| 2921 | * @param string $database The name of the database that should be created. |
||
| 2922 | * |
||
| 2923 | * @return string |
||
| 2924 | * |
||
| 2925 | * @throws DBALException If not supported on this platform. |
||
| 2926 | */ |
||
| 2927 | 46427 | public function getCreateDatabaseSQL($database) |
|
| 2931 | |||
| 2932 | /** |
||
| 2933 | * Returns the SQL to set the transaction isolation level. |
||
| 2934 | * |
||
| 2935 | * @param int $level |
||
| 2936 | * |
||
| 2937 | * @return string |
||
| 2938 | * |
||
| 2939 | * @throws DBALException If not supported on this platform. |
||
| 2940 | */ |
||
| 2941 | public function getSetTransactionIsolationSQL($level) |
||
| 2945 | |||
| 2946 | /** |
||
| 2947 | * Obtains DBMS specific SQL to be used to create datetime fields in |
||
| 2948 | * statements like CREATE TABLE. |
||
| 2949 | * |
||
| 2950 | * @param mixed[] $fieldDeclaration |
||
| 2951 | * |
||
| 2952 | * @return string |
||
| 2953 | * |
||
| 2954 | * @throws DBALException If not supported on this platform. |
||
| 2955 | */ |
||
| 2956 | public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 2960 | |||
| 2961 | /** |
||
| 2962 | * Obtains DBMS specific SQL to be used to create datetime with timezone offset fields. |
||
| 2963 | * |
||
| 2964 | * @param mixed[] $fieldDeclaration |
||
| 2965 | * |
||
| 2966 | * @return string |
||
| 2967 | */ |
||
| 2968 | 37450 | public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
|
| 2972 | |||
| 2973 | /** |
||
| 2974 | * Obtains DBMS specific SQL to be used to create date fields in statements |
||
| 2975 | * like CREATE TABLE. |
||
| 2976 | * |
||
| 2977 | * @param mixed[] $fieldDeclaration |
||
| 2978 | * |
||
| 2979 | * @return string |
||
| 2980 | * |
||
| 2981 | * @throws DBALException If not supported on this platform. |
||
| 2982 | */ |
||
| 2983 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
||
| 2987 | |||
| 2988 | /** |
||
| 2989 | * Obtains DBMS specific SQL to be used to create time fields in statements |
||
| 2990 | * like CREATE TABLE. |
||
| 2991 | * |
||
| 2992 | * @param mixed[] $fieldDeclaration |
||
| 2993 | * |
||
| 2994 | * @return string |
||
| 2995 | * |
||
| 2996 | * @throws DBALException If not supported on this platform. |
||
| 2997 | */ |
||
| 2998 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3002 | |||
| 3003 | /** |
||
| 3004 | * @param mixed[] $fieldDeclaration |
||
| 3005 | * |
||
| 3006 | * @return string |
||
| 3007 | */ |
||
| 3008 | 57529 | public function getFloatDeclarationSQL(array $fieldDeclaration) |
|
| 3012 | |||
| 3013 | /** |
||
| 3014 | * Gets the default transaction isolation level of the platform. |
||
| 3015 | * |
||
| 3016 | * @see TransactionIsolationLevel |
||
| 3017 | * |
||
| 3018 | * @return int The default isolation level. |
||
| 3019 | */ |
||
| 3020 | public function getDefaultTransactionIsolationLevel() |
||
| 3024 | |||
| 3025 | /* supports*() methods */ |
||
| 3026 | |||
| 3027 | /** |
||
| 3028 | * Whether the platform supports sequences. |
||
| 3029 | * |
||
| 3030 | * @return bool |
||
| 3031 | */ |
||
| 3032 | 40114 | public function supportsSequences() |
|
| 3036 | |||
| 3037 | /** |
||
| 3038 | * Whether the platform supports identity columns. |
||
| 3039 | * |
||
| 3040 | * Identity columns are columns that receive an auto-generated value from the |
||
| 3041 | * database on insert of a row. |
||
| 3042 | * |
||
| 3043 | * @return bool |
||
| 3044 | */ |
||
| 3045 | 4 | public function supportsIdentityColumns() |
|
| 3049 | |||
| 3050 | /** |
||
| 3051 | * Whether the platform emulates identity columns through sequences. |
||
| 3052 | * |
||
| 3053 | * Some platforms that do not support identity columns natively |
||
| 3054 | * but support sequences can emulate identity columns by using |
||
| 3055 | * sequences. |
||
| 3056 | * |
||
| 3057 | * @return bool |
||
| 3058 | */ |
||
| 3059 | 57281 | public function usesSequenceEmulatedIdentityColumns() |
|
| 3063 | |||
| 3064 | /** |
||
| 3065 | * Returns the name of the sequence for a particular identity column in a particular table. |
||
| 3066 | * |
||
| 3067 | * @see usesSequenceEmulatedIdentityColumns |
||
| 3068 | * |
||
| 3069 | * @param string $tableName The name of the table to return the sequence name for. |
||
| 3070 | * @param string $columnName The name of the identity column in the table to return the sequence name for. |
||
| 3071 | * |
||
| 3072 | * @return string |
||
| 3073 | * |
||
| 3074 | * @throws DBALException If not supported on this platform. |
||
| 3075 | */ |
||
| 3076 | 55924 | public function getIdentitySequenceName($tableName, $columnName) |
|
| 3080 | |||
| 3081 | /** |
||
| 3082 | * Whether the platform supports indexes. |
||
| 3083 | * |
||
| 3084 | * @return bool |
||
| 3085 | */ |
||
| 3086 | 8 | public function supportsIndexes() |
|
| 3090 | |||
| 3091 | /** |
||
| 3092 | * Whether the platform supports partial indexes. |
||
| 3093 | * |
||
| 3094 | * @return bool |
||
| 3095 | */ |
||
| 3096 | 61034 | public function supportsPartialIndexes() |
|
| 3100 | |||
| 3101 | /** |
||
| 3102 | * Whether the platform supports indexes with column length definitions. |
||
| 3103 | */ |
||
| 3104 | 60665 | public function supportsColumnLengthIndexes() : bool |
|
| 3108 | |||
| 3109 | /** |
||
| 3110 | * Whether the platform supports altering tables. |
||
| 3111 | * |
||
| 3112 | * @return bool |
||
| 3113 | */ |
||
| 3114 | 59987 | public function supportsAlterTable() |
|
| 3118 | |||
| 3119 | /** |
||
| 3120 | * Whether the platform supports transactions. |
||
| 3121 | * |
||
| 3122 | * @return bool |
||
| 3123 | */ |
||
| 3124 | 8 | public function supportsTransactions() |
|
| 3128 | |||
| 3129 | /** |
||
| 3130 | * Whether the platform supports savepoints. |
||
| 3131 | * |
||
| 3132 | * @return bool |
||
| 3133 | */ |
||
| 3134 | 61703 | public function supportsSavepoints() |
|
| 3138 | |||
| 3139 | /** |
||
| 3140 | * Whether the platform supports releasing savepoints. |
||
| 3141 | * |
||
| 3142 | * @return bool |
||
| 3143 | */ |
||
| 3144 | 58900 | public function supportsReleaseSavepoints() |
|
| 3148 | |||
| 3149 | /** |
||
| 3150 | * Whether the platform supports primary key constraints. |
||
| 3151 | * |
||
| 3152 | * @return bool |
||
| 3153 | */ |
||
| 3154 | 8 | public function supportsPrimaryConstraints() |
|
| 3158 | |||
| 3159 | /** |
||
| 3160 | * Whether the platform supports foreign key constraints. |
||
| 3161 | * |
||
| 3162 | * @return bool |
||
| 3163 | */ |
||
| 3164 | 62874 | public function supportsForeignKeyConstraints() |
|
| 3168 | |||
| 3169 | /** |
||
| 3170 | * Whether this platform supports onUpdate in foreign key constraints. |
||
| 3171 | * |
||
| 3172 | * @return bool |
||
| 3173 | */ |
||
| 3174 | 62121 | public function supportsForeignKeyOnUpdate() |
|
| 3178 | |||
| 3179 | /** |
||
| 3180 | * Whether the platform supports database schemas. |
||
| 3181 | * |
||
| 3182 | * @return bool |
||
| 3183 | */ |
||
| 3184 | 40124 | public function supportsSchemas() |
|
| 3188 | |||
| 3189 | /** |
||
| 3190 | * Whether this platform can emulate schemas. |
||
| 3191 | * |
||
| 3192 | * Platforms that either support or emulate schemas don't automatically |
||
| 3193 | * filter a schema for the namespaced elements in {@link |
||
| 3194 | * AbstractManager#createSchema}. |
||
| 3195 | * |
||
| 3196 | * @return bool |
||
| 3197 | */ |
||
| 3198 | 8 | public function canEmulateSchemas() |
|
| 3202 | |||
| 3203 | /** |
||
| 3204 | * Returns the default schema name. |
||
| 3205 | * |
||
| 3206 | * @return string |
||
| 3207 | * |
||
| 3208 | * @throws DBALException If not supported on this platform. |
||
| 3209 | */ |
||
| 3210 | public function getDefaultSchemaName() |
||
| 3214 | |||
| 3215 | /** |
||
| 3216 | * Whether this platform supports create database. |
||
| 3217 | * |
||
| 3218 | * Some databases don't allow to create and drop databases at all or only with certain tools. |
||
| 3219 | * |
||
| 3220 | * @return bool |
||
| 3221 | */ |
||
| 3222 | 57964 | public function supportsCreateDropDatabase() |
|
| 3226 | |||
| 3227 | /** |
||
| 3228 | * Whether the platform supports getting the affected rows of a recent update/delete type query. |
||
| 3229 | * |
||
| 3230 | * @return bool |
||
| 3231 | */ |
||
| 3232 | 8 | public function supportsGettingAffectedRows() |
|
| 3236 | |||
| 3237 | /** |
||
| 3238 | * Whether this platform support to add inline column comments as postfix. |
||
| 3239 | * |
||
| 3240 | * @return bool |
||
| 3241 | */ |
||
| 3242 | 60041 | public function supportsInlineColumnComments() |
|
| 3246 | |||
| 3247 | /** |
||
| 3248 | * Whether this platform support the proprietary syntax "COMMENT ON asset". |
||
| 3249 | * |
||
| 3250 | * @return bool |
||
| 3251 | */ |
||
| 3252 | 60891 | public function supportsCommentOnStatement() |
|
| 3256 | |||
| 3257 | /** |
||
| 3258 | * Does this platform have native guid type. |
||
| 3259 | * |
||
| 3260 | * @return bool |
||
| 3261 | */ |
||
| 3262 | 61870 | public function hasNativeGuidType() |
|
| 3266 | |||
| 3267 | /** |
||
| 3268 | * Does this platform have native JSON type. |
||
| 3269 | * |
||
| 3270 | * @return bool |
||
| 3271 | */ |
||
| 3272 | 62091 | public function hasNativeJsonType() |
|
| 3276 | |||
| 3277 | /** |
||
| 3278 | * @deprecated |
||
| 3279 | * |
||
| 3280 | * @todo Remove in 3.0 |
||
| 3281 | */ |
||
| 3282 | public function getIdentityColumnNullInsertSQL() |
||
| 3286 | |||
| 3287 | /** |
||
| 3288 | * Whether this platform supports views. |
||
| 3289 | * |
||
| 3290 | * @return bool |
||
| 3291 | */ |
||
| 3292 | 59945 | public function supportsViews() |
|
| 3296 | |||
| 3297 | /** |
||
| 3298 | * Does this platform support column collation? |
||
| 3299 | * |
||
| 3300 | * @return bool |
||
| 3301 | */ |
||
| 3302 | public function supportsColumnCollation() |
||
| 3306 | |||
| 3307 | /** |
||
| 3308 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3309 | * the format of a stored datetime value of this platform. |
||
| 3310 | * |
||
| 3311 | * @return string The format string. |
||
| 3312 | */ |
||
| 3313 | 57968 | public function getDateTimeFormatString() |
|
| 3317 | |||
| 3318 | /** |
||
| 3319 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3320 | * the format of a stored datetime with timezone value of this platform. |
||
| 3321 | * |
||
| 3322 | * @return string The format string. |
||
| 3323 | */ |
||
| 3324 | 37696 | public function getDateTimeTzFormatString() |
|
| 3328 | |||
| 3329 | /** |
||
| 3330 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3331 | * the format of a stored date value of this platform. |
||
| 3332 | * |
||
| 3333 | * @return string The format string. |
||
| 3334 | */ |
||
| 3335 | 53686 | public function getDateFormatString() |
|
| 3339 | |||
| 3340 | /** |
||
| 3341 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3342 | * the format of a stored time value of this platform. |
||
| 3343 | * |
||
| 3344 | * @return string The format string. |
||
| 3345 | */ |
||
| 3346 | 44331 | public function getTimeFormatString() |
|
| 3350 | |||
| 3351 | /** |
||
| 3352 | * Adds an driver-specific LIMIT clause to the query. |
||
| 3353 | * |
||
| 3354 | * @param string $query |
||
| 3355 | * @param int|null $limit |
||
| 3356 | * @param int|null $offset |
||
| 3357 | * |
||
| 3358 | * @return string |
||
| 3359 | * |
||
| 3360 | * @throws DBALException |
||
| 3361 | */ |
||
| 3362 | 62031 | final public function modifyLimitQuery($query, $limit, $offset = null) |
|
| 3386 | |||
| 3387 | /** |
||
| 3388 | * Adds an platform-specific LIMIT clause to the query. |
||
| 3389 | * |
||
| 3390 | * @param string $query |
||
| 3391 | * @param int|null $limit |
||
| 3392 | * @param int|null $offset |
||
| 3393 | * |
||
| 3394 | * @return string |
||
| 3395 | */ |
||
| 3396 | 49211 | protected function doModifyLimitQuery($query, $limit, $offset) |
|
| 3408 | |||
| 3409 | /** |
||
| 3410 | * Whether the database platform support offsets in modify limit clauses. |
||
| 3411 | * |
||
| 3412 | * @return bool |
||
| 3413 | */ |
||
| 3414 | 61478 | public function supportsLimitOffset() |
|
| 3418 | |||
| 3419 | /** |
||
| 3420 | * Gets the character casing of a column in an SQL result set of this platform. |
||
| 3421 | * |
||
| 3422 | * @param string $column The column name for which to get the correct character casing. |
||
| 3423 | * |
||
| 3424 | * @return string The column name in the character casing used in SQL result sets. |
||
| 3425 | */ |
||
| 3426 | public function getSQLResultCasing($column) |
||
| 3430 | |||
| 3431 | /** |
||
| 3432 | * Makes any fixes to a name of a schema element (table, sequence, ...) that are required |
||
| 3433 | * by restrictions of the platform, like a maximum length. |
||
| 3434 | * |
||
| 3435 | * @param string $schemaElementName |
||
| 3436 | * |
||
| 3437 | * @return string |
||
| 3438 | */ |
||
| 3439 | public function fixSchemaElementName($schemaElementName) |
||
| 3443 | |||
| 3444 | /** |
||
| 3445 | * Maximum length of any given database identifier, like tables or column names. |
||
| 3446 | * |
||
| 3447 | * @return int |
||
| 3448 | */ |
||
| 3449 | 61203 | public function getMaxIdentifierLength() |
|
| 3453 | |||
| 3454 | /** |
||
| 3455 | * Returns the insert SQL for an empty insert statement. |
||
| 3456 | * |
||
| 3457 | * @param string $tableName |
||
| 3458 | * @param string $identifierColumnName |
||
| 3459 | * |
||
| 3460 | * @return string |
||
| 3461 | */ |
||
| 3462 | 34666 | public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) |
|
| 3466 | |||
| 3467 | /** |
||
| 3468 | * Generates a Truncate Table SQL statement for a given table. |
||
| 3469 | * |
||
| 3470 | * Cascade is not supported on many platforms but would optionally cascade the truncate by |
||
| 3471 | * following the foreign keys. |
||
| 3472 | * |
||
| 3473 | * @param string $tableName |
||
| 3474 | * @param bool $cascade |
||
| 3475 | * |
||
| 3476 | * @return string |
||
| 3477 | */ |
||
| 3478 | 58295 | public function getTruncateTableSQL($tableName, $cascade = false) |
|
| 3484 | |||
| 3485 | /** |
||
| 3486 | * This is for test reasons, many vendors have special requirements for dummy statements. |
||
| 3487 | * |
||
| 3488 | * @return string |
||
| 3489 | */ |
||
| 3490 | 62997 | public function getDummySelectSQL() |
|
| 3496 | |||
| 3497 | /** |
||
| 3498 | * Returns the SQL to create a new savepoint. |
||
| 3499 | * |
||
| 3500 | * @param string $savepoint |
||
| 3501 | * |
||
| 3502 | * @return string |
||
| 3503 | */ |
||
| 3504 | 55621 | public function createSavePoint($savepoint) |
|
| 3508 | |||
| 3509 | /** |
||
| 3510 | * Returns the SQL to release a savepoint. |
||
| 3511 | * |
||
| 3512 | * @param string $savepoint |
||
| 3513 | * |
||
| 3514 | * @return string |
||
| 3515 | */ |
||
| 3516 | 55619 | public function releaseSavePoint($savepoint) |
|
| 3520 | |||
| 3521 | /** |
||
| 3522 | * Returns the SQL to rollback a savepoint. |
||
| 3523 | * |
||
| 3524 | * @param string $savepoint |
||
| 3525 | * |
||
| 3526 | * @return string |
||
| 3527 | */ |
||
| 3528 | 55621 | public function rollbackSavePoint($savepoint) |
|
| 3532 | |||
| 3533 | /** |
||
| 3534 | * Returns the keyword list instance of this platform. |
||
| 3535 | * |
||
| 3536 | * @return KeywordList |
||
| 3537 | * |
||
| 3538 | * @throws DBALException If no keyword list is specified. |
||
| 3539 | */ |
||
| 3540 | 65482 | final public function getReservedKeywordsList() |
|
| 3558 | |||
| 3559 | /** |
||
| 3560 | * Returns the class name of the reserved keywords list. |
||
| 3561 | * |
||
| 3562 | * @return string |
||
| 3563 | * |
||
| 3564 | * @throws DBALException If not supported on this platform. |
||
| 3565 | */ |
||
| 3566 | protected function getReservedKeywordsClass() |
||
| 3570 | |||
| 3571 | /** |
||
| 3572 | * Quotes a literal string. |
||
| 3573 | * This method is NOT meant to fix SQL injections! |
||
| 3574 | * It is only meant to escape this platform's string literal |
||
| 3575 | * quote character inside the given literal string. |
||
| 3576 | * |
||
| 3577 | * @param string $str The literal string to be quoted. |
||
| 3578 | * |
||
| 3579 | * @return string The quoted literal string. |
||
| 3580 | */ |
||
| 3581 | 62345 | public function quoteStringLiteral($str) |
|
| 3587 | |||
| 3588 | /** |
||
| 3589 | * Gets the character used for string literal quoting. |
||
| 3590 | * |
||
| 3591 | * @return string |
||
| 3592 | */ |
||
| 3593 | 62381 | public function getStringLiteralQuoteCharacter() |
|
| 3597 | |||
| 3598 | /** |
||
| 3599 | * Escapes metacharacters in a string intended to be used with a LIKE |
||
| 3600 | * operator. |
||
| 3601 | * |
||
| 3602 | * @param string $inputString a literal, unquoted string |
||
| 3603 | * @param string $escapeChar should be reused by the caller in the LIKE |
||
| 3604 | * expression. |
||
| 3605 | */ |
||
| 3606 | 61988 | final public function escapeStringForLike(string $inputString, string $escapeChar) : string |
|
| 3614 | |||
| 3615 | 61988 | protected function getLikeWildcardCharacters() : string |
|
| 3619 | } |
||
| 3620 |
If you suppress an error, we recommend checking for the error condition explicitly: