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 |
||
| 88 | abstract class AbstractPlatform |
||
| 89 | { |
||
| 90 | /** |
||
| 91 | * @var int |
||
| 92 | */ |
||
| 93 | const CREATE_INDEXES = 1; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var int |
||
| 97 | */ |
||
| 98 | const CREATE_FOREIGNKEYS = 2; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @deprecated Use DateIntervalUnit::INTERVAL_UNIT_SECOND. |
||
| 102 | */ |
||
| 103 | public const DATE_INTERVAL_UNIT_SECOND = DateIntervalUnit::SECOND; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @deprecated Use DateIntervalUnit::MINUTE. |
||
| 107 | */ |
||
| 108 | public const DATE_INTERVAL_UNIT_MINUTE = DateIntervalUnit::MINUTE; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @deprecated Use DateIntervalUnit::HOUR. |
||
| 112 | */ |
||
| 113 | public const DATE_INTERVAL_UNIT_HOUR = DateIntervalUnit::HOUR; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @deprecated Use DateIntervalUnit::DAY. |
||
| 117 | */ |
||
| 118 | public const DATE_INTERVAL_UNIT_DAY = DateIntervalUnit::DAY; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @deprecated Use DateIntervalUnit::WEEK. |
||
| 122 | */ |
||
| 123 | public const DATE_INTERVAL_UNIT_WEEK = DateIntervalUnit::WEEK; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @deprecated Use DateIntervalUnit::MONTH. |
||
| 127 | */ |
||
| 128 | public const DATE_INTERVAL_UNIT_MONTH = DateIntervalUnit::MONTH; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @deprecated Use DateIntervalUnit::QUARTER. |
||
| 132 | */ |
||
| 133 | public const DATE_INTERVAL_UNIT_QUARTER = DateIntervalUnit::QUARTER; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @deprecated Use DateIntervalUnit::QUARTER. |
||
| 137 | */ |
||
| 138 | public const DATE_INTERVAL_UNIT_YEAR = DateIntervalUnit::YEAR; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @var int |
||
| 142 | * |
||
| 143 | * @deprecated Use TrimMode::UNSPECIFIED. |
||
| 144 | */ |
||
| 145 | public const TRIM_UNSPECIFIED = TrimMode::UNSPECIFIED; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var int |
||
| 149 | * |
||
| 150 | * @deprecated Use TrimMode::LEADING. |
||
| 151 | */ |
||
| 152 | public const TRIM_LEADING = TrimMode::LEADING; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @var int |
||
| 156 | * |
||
| 157 | * @deprecated Use TrimMode::TRAILING. |
||
| 158 | */ |
||
| 159 | public const TRIM_TRAILING = TrimMode::TRAILING; |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @var int |
||
| 163 | * |
||
| 164 | * @deprecated Use TrimMode::BOTH. |
||
| 165 | */ |
||
| 166 | public const TRIM_BOTH = TrimMode::BOTH; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @var array|null |
||
| 170 | */ |
||
| 171 | protected $doctrineTypeMapping = null; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Contains a list of all columns that should generate parseable column comments for type-detection |
||
| 175 | * in reverse engineering scenarios. |
||
| 176 | * |
||
| 177 | * @var array|null |
||
| 178 | */ |
||
| 179 | protected $doctrineTypeComments = null; |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @var \Doctrine\Common\EventManager |
||
| 183 | */ |
||
| 184 | protected $_eventManager; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Holds the KeywordList instance for the current platform. |
||
| 188 | * |
||
| 189 | * @var \Doctrine\DBAL\Platforms\Keywords\KeywordList |
||
| 190 | */ |
||
| 191 | protected $_keywords; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Constructor. |
||
| 195 | */ |
||
| 196 | public function __construct() |
||
| 199 | |||
| 200 | /** |
||
| 201 | * Sets the EventManager used by the Platform. |
||
| 202 | * |
||
| 203 | * @param \Doctrine\Common\EventManager $eventManager |
||
| 204 | */ |
||
| 205 | public function setEventManager(EventManager $eventManager) |
||
| 209 | |||
| 210 | /** |
||
| 211 | * Gets the EventManager used by the Platform. |
||
| 212 | * |
||
| 213 | * @return \Doctrine\Common\EventManager |
||
| 214 | */ |
||
| 215 | public function getEventManager() |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Returns the SQL snippet that declares a boolean column. |
||
| 222 | * |
||
| 223 | * @param array $columnDef |
||
| 224 | * |
||
| 225 | * @return string |
||
| 226 | */ |
||
| 227 | abstract public function getBooleanTypeDeclarationSQL(array $columnDef); |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Returns the SQL snippet that declares a 4 byte integer column. |
||
| 231 | * |
||
| 232 | * @param array $columnDef |
||
| 233 | * |
||
| 234 | * @return string |
||
| 235 | */ |
||
| 236 | abstract public function getIntegerTypeDeclarationSQL(array $columnDef); |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Returns the SQL snippet that declares an 8 byte integer column. |
||
| 240 | * |
||
| 241 | * @param array $columnDef |
||
| 242 | * |
||
| 243 | * @return string |
||
| 244 | */ |
||
| 245 | abstract public function getBigIntTypeDeclarationSQL(array $columnDef); |
||
| 246 | |||
| 247 | /** |
||
| 248 | * Returns the SQL snippet that declares a 2 byte integer column. |
||
| 249 | * |
||
| 250 | * @param array $columnDef |
||
| 251 | * |
||
| 252 | * @return string |
||
| 253 | */ |
||
| 254 | abstract public function getSmallIntTypeDeclarationSQL(array $columnDef); |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Returns the SQL snippet that declares common properties of an integer column. |
||
| 258 | * |
||
| 259 | * @param array $columnDef |
||
| 260 | * |
||
| 261 | * @return string |
||
| 262 | */ |
||
| 263 | abstract protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef); |
||
| 264 | |||
| 265 | /** |
||
| 266 | * Lazy load Doctrine Type Mappings. |
||
| 267 | * |
||
| 268 | * @return void |
||
| 269 | */ |
||
| 270 | abstract protected function initializeDoctrineTypeMappings(); |
||
| 271 | |||
| 272 | /** |
||
| 273 | * Initializes Doctrine Type Mappings with the platform defaults |
||
| 274 | * and with all additional type mappings. |
||
| 275 | * |
||
| 276 | * @return void |
||
| 277 | */ |
||
| 278 | private function initializeAllDoctrineTypeMappings() |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Returns the SQL snippet used to declare a VARCHAR column type. |
||
| 291 | * |
||
| 292 | * @param array $field |
||
| 293 | * |
||
| 294 | * @return string |
||
| 295 | */ |
||
| 296 | public function getVarcharTypeDeclarationSQL(array $field) |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 317 | * |
||
| 318 | * @param array $field The column definition. |
||
| 319 | * |
||
| 320 | * @return string |
||
| 321 | */ |
||
| 322 | public function getBinaryTypeDeclarationSQL(array $field) |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Returns the SQL snippet to declare a GUID/UUID field. |
||
| 349 | * |
||
| 350 | * By default this maps directly to a CHAR(36) and only maps to more |
||
| 351 | * special datatypes when the underlying databases support this datatype. |
||
| 352 | * |
||
| 353 | * @param array $field |
||
| 354 | * |
||
| 355 | * @return string |
||
| 356 | */ |
||
| 357 | public function getGuidTypeDeclarationSQL(array $field) |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Returns the SQL snippet to declare a JSON field. |
||
| 367 | * |
||
| 368 | * By default this maps directly to a CLOB and only maps to more |
||
| 369 | * special datatypes when the underlying databases support this datatype. |
||
| 370 | * |
||
| 371 | * @param array $field |
||
| 372 | * |
||
| 373 | * @return string |
||
| 374 | */ |
||
| 375 | public function getJsonTypeDeclarationSQL(array $field) |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param int $length |
||
| 382 | * @param bool $fixed |
||
| 383 | * |
||
| 384 | * @return string |
||
|
|
|||
| 385 | * |
||
| 386 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 387 | */ |
||
| 388 | protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
| 395 | * |
||
| 396 | * @param int $length The length of the column. |
||
| 397 | * @param bool $fixed Whether the column length is fixed. |
||
| 398 | * |
||
| 399 | * @return string |
||
| 400 | * |
||
| 401 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 402 | */ |
||
| 403 | protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) |
||
| 407 | |||
| 408 | /** |
||
| 409 | * Returns the SQL snippet used to declare a CLOB column type. |
||
| 410 | * |
||
| 411 | * @param array $field |
||
| 412 | * |
||
| 413 | * @return string |
||
| 414 | */ |
||
| 415 | abstract public function getClobTypeDeclarationSQL(array $field); |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Returns the SQL Snippet used to declare a BLOB column type. |
||
| 419 | * |
||
| 420 | * @param array $field |
||
| 421 | * |
||
| 422 | * @return string |
||
| 423 | */ |
||
| 424 | abstract public function getBlobTypeDeclarationSQL(array $field); |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Gets the name of the platform. |
||
| 428 | * |
||
| 429 | * @return string |
||
| 430 | */ |
||
| 431 | abstract public function getName(); |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Registers a doctrine type to be used in conjunction with a column type of this platform. |
||
| 435 | * |
||
| 436 | * @param string $dbType |
||
| 437 | * @param string $doctrineType |
||
| 438 | * |
||
| 439 | * @throws \Doctrine\DBAL\DBALException If the type is not found. |
||
| 440 | */ |
||
| 441 | public function registerDoctrineTypeMapping($dbType, $doctrineType) |
||
| 460 | |||
| 461 | /** |
||
| 462 | * Gets the Doctrine type that is mapped for the given database column type. |
||
| 463 | * |
||
| 464 | * @param string $dbType |
||
| 465 | * |
||
| 466 | * @return string |
||
| 467 | * |
||
| 468 | * @throws \Doctrine\DBAL\DBALException |
||
| 469 | */ |
||
| 470 | public function getDoctrineTypeMapping($dbType) |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Checks if a database type is currently supported by this platform. |
||
| 487 | * |
||
| 488 | * @param string $dbType |
||
| 489 | * |
||
| 490 | * @return bool |
||
| 491 | */ |
||
| 492 | public function hasDoctrineTypeMappingFor($dbType) |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Initializes the Doctrine Type comments instance variable for in_array() checks. |
||
| 505 | * |
||
| 506 | * @return void |
||
| 507 | */ |
||
| 508 | protected function initializeCommentedDoctrineTypes() |
||
| 520 | |||
| 521 | /** |
||
| 522 | * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type? |
||
| 523 | * |
||
| 524 | * @param \Doctrine\DBAL\Types\Type $doctrineType |
||
| 525 | * |
||
| 526 | * @return bool |
||
| 527 | */ |
||
| 528 | public function isCommentedDoctrineType(Type $doctrineType) |
||
| 536 | |||
| 537 | /** |
||
| 538 | * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements. |
||
| 539 | * |
||
| 540 | * @param string|\Doctrine\DBAL\Types\Type $doctrineType |
||
| 541 | * |
||
| 542 | * @return void |
||
| 543 | */ |
||
| 544 | public function markDoctrineTypeCommented($doctrineType) |
||
| 552 | |||
| 553 | /** |
||
| 554 | * Gets the comment to append to a column comment that helps parsing this type in reverse engineering. |
||
| 555 | * |
||
| 556 | * @param \Doctrine\DBAL\Types\Type $doctrineType |
||
| 557 | * |
||
| 558 | * @return string |
||
| 559 | */ |
||
| 560 | public function getDoctrineTypeComment(Type $doctrineType) |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Gets the comment of a passed column modified by potential doctrine type comment hints. |
||
| 567 | * |
||
| 568 | * @param \Doctrine\DBAL\Schema\Column $column |
||
| 569 | * |
||
| 570 | * @return string |
||
| 571 | */ |
||
| 572 | protected function getColumnComment(Column $column) |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Gets the character used for identifier quoting. |
||
| 585 | * |
||
| 586 | * @return string |
||
| 587 | */ |
||
| 588 | public function getIdentifierQuoteCharacter() |
||
| 592 | |||
| 593 | /** |
||
| 594 | * Gets the string portion that starts an SQL comment. |
||
| 595 | * |
||
| 596 | * @return string |
||
| 597 | */ |
||
| 598 | public function getSqlCommentStartString() |
||
| 602 | |||
| 603 | /** |
||
| 604 | * Gets the string portion that ends an SQL comment. |
||
| 605 | * |
||
| 606 | * @return string |
||
| 607 | */ |
||
| 608 | public function getSqlCommentEndString() |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Gets the maximum length of a char field. |
||
| 615 | */ |
||
| 616 | public function getCharMaxLength() : int |
||
| 620 | |||
| 621 | /** |
||
| 622 | * Gets the maximum length of a varchar field. |
||
| 623 | * |
||
| 624 | * @return int |
||
| 625 | */ |
||
| 626 | public function getVarcharMaxLength() |
||
| 630 | |||
| 631 | /** |
||
| 632 | * Gets the default length of a varchar field. |
||
| 633 | * |
||
| 634 | * @return int |
||
| 635 | */ |
||
| 636 | public function getVarcharDefaultLength() |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Gets the maximum length of a binary field. |
||
| 643 | * |
||
| 644 | * @return int |
||
| 645 | */ |
||
| 646 | public function getBinaryMaxLength() |
||
| 650 | |||
| 651 | /** |
||
| 652 | * Gets the default length of a binary field. |
||
| 653 | * |
||
| 654 | * @return int |
||
| 655 | */ |
||
| 656 | public function getBinaryDefaultLength() |
||
| 660 | |||
| 661 | /** |
||
| 662 | * Gets all SQL wildcard characters of the platform. |
||
| 663 | * |
||
| 664 | * @return array |
||
| 665 | */ |
||
| 666 | public function getWildcards() |
||
| 670 | |||
| 671 | /** |
||
| 672 | * Returns the regular expression operator. |
||
| 673 | * |
||
| 674 | * @return string |
||
| 675 | * |
||
| 676 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 677 | */ |
||
| 678 | public function getRegexpExpression() |
||
| 682 | |||
| 683 | /** |
||
| 684 | * Returns the global unique identifier expression. |
||
| 685 | * |
||
| 686 | * @return string |
||
| 687 | * |
||
| 688 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 689 | * |
||
| 690 | * @deprecated Use application-generated UUIDs instead |
||
| 691 | */ |
||
| 692 | public function getGuidExpression() |
||
| 696 | |||
| 697 | /** |
||
| 698 | * Returns the SQL snippet to get the average value of a column. |
||
| 699 | * |
||
| 700 | * @param string $column The column to use. |
||
| 701 | * |
||
| 702 | * @return string Generated SQL including an AVG aggregate function. |
||
| 703 | */ |
||
| 704 | public function getAvgExpression($column) |
||
| 708 | |||
| 709 | /** |
||
| 710 | * Returns the SQL snippet to get the number of rows (without a NULL value) of a column. |
||
| 711 | * |
||
| 712 | * If a '*' is used instead of a column the number of selected rows is returned. |
||
| 713 | * |
||
| 714 | * @param string|integer $column The column to use. |
||
| 715 | * |
||
| 716 | * @return string Generated SQL including a COUNT aggregate function. |
||
| 717 | */ |
||
| 718 | public function getCountExpression($column) |
||
| 722 | |||
| 723 | /** |
||
| 724 | * Returns the SQL snippet to get the highest value of a column. |
||
| 725 | * |
||
| 726 | * @param string $column The column to use. |
||
| 727 | * |
||
| 728 | * @return string Generated SQL including a MAX aggregate function. |
||
| 729 | */ |
||
| 730 | public function getMaxExpression($column) |
||
| 734 | |||
| 735 | /** |
||
| 736 | * Returns the SQL snippet to get the lowest value of a column. |
||
| 737 | * |
||
| 738 | * @param string $column The column to use. |
||
| 739 | * |
||
| 740 | * @return string Generated SQL including a MIN aggregate function. |
||
| 741 | */ |
||
| 742 | public function getMinExpression($column) |
||
| 746 | |||
| 747 | /** |
||
| 748 | * Returns the SQL snippet to get the total sum of a column. |
||
| 749 | * |
||
| 750 | * @param string $column The column to use. |
||
| 751 | * |
||
| 752 | * @return string Generated SQL including a SUM aggregate function. |
||
| 753 | */ |
||
| 754 | public function getSumExpression($column) |
||
| 758 | |||
| 759 | // scalar functions |
||
| 760 | |||
| 761 | /** |
||
| 762 | * Returns the SQL snippet to get the md5 sum of a field. |
||
| 763 | * |
||
| 764 | * Note: Not SQL92, but common functionality. |
||
| 765 | * |
||
| 766 | * @param string $column |
||
| 767 | * |
||
| 768 | * @return string |
||
| 769 | */ |
||
| 770 | public function getMd5Expression($column) |
||
| 774 | |||
| 775 | /** |
||
| 776 | * Returns the SQL snippet to get the length of a text field. |
||
| 777 | * |
||
| 778 | * @param string $column |
||
| 779 | * |
||
| 780 | * @return string |
||
| 781 | */ |
||
| 782 | public function getLengthExpression($column) |
||
| 786 | |||
| 787 | /** |
||
| 788 | * Returns the SQL snippet to get the squared value of a column. |
||
| 789 | * |
||
| 790 | * @param string $column The column to use. |
||
| 791 | * |
||
| 792 | * @return string Generated SQL including an SQRT aggregate function. |
||
| 793 | */ |
||
| 794 | public function getSqrtExpression($column) |
||
| 798 | |||
| 799 | /** |
||
| 800 | * Returns the SQL snippet to round a numeric field to the number of decimals specified. |
||
| 801 | * |
||
| 802 | * @param string $column |
||
| 803 | * @param int $decimals |
||
| 804 | * |
||
| 805 | * @return string |
||
| 806 | */ |
||
| 807 | public function getRoundExpression($column, $decimals = 0) |
||
| 811 | |||
| 812 | /** |
||
| 813 | * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2. |
||
| 814 | * |
||
| 815 | * @param string $expression1 |
||
| 816 | * @param string $expression2 |
||
| 817 | * |
||
| 818 | * @return string |
||
| 819 | */ |
||
| 820 | public function getModExpression($expression1, $expression2) |
||
| 824 | |||
| 825 | /** |
||
| 826 | * Returns the SQL snippet to trim a string. |
||
| 827 | * |
||
| 828 | * @param string $str The expression to apply the trim to. |
||
| 829 | * @param int $mode The position of the trim (leading/trailing/both). |
||
| 830 | * @param string|bool $char The char to trim, has to be quoted already. Defaults to space. |
||
| 831 | * |
||
| 832 | * @return string |
||
| 833 | */ |
||
| 834 | public function getTrimExpression($str, $mode = TrimMode::UNSPECIFIED, $char = false) |
||
| 862 | |||
| 863 | /** |
||
| 864 | * Returns the SQL snippet to trim trailing space characters from the expression. |
||
| 865 | * |
||
| 866 | * @param string $str Literal string or column name. |
||
| 867 | * |
||
| 868 | * @return string |
||
| 869 | */ |
||
| 870 | public function getRtrimExpression($str) |
||
| 874 | |||
| 875 | /** |
||
| 876 | * Returns the SQL snippet to trim leading space characters from the expression. |
||
| 877 | * |
||
| 878 | * @param string $str Literal string or column name. |
||
| 879 | * |
||
| 880 | * @return string |
||
| 881 | */ |
||
| 882 | public function getLtrimExpression($str) |
||
| 886 | |||
| 887 | /** |
||
| 888 | * Returns the SQL snippet to change all characters from the expression to uppercase, |
||
| 889 | * according to the current character set mapping. |
||
| 890 | * |
||
| 891 | * @param string $str Literal string or column name. |
||
| 892 | * |
||
| 893 | * @return string |
||
| 894 | */ |
||
| 895 | public function getUpperExpression($str) |
||
| 899 | |||
| 900 | /** |
||
| 901 | * Returns the SQL snippet to change all characters from the expression to lowercase, |
||
| 902 | * according to the current character set mapping. |
||
| 903 | * |
||
| 904 | * @param string $str Literal string or column name. |
||
| 905 | * |
||
| 906 | * @return string |
||
| 907 | */ |
||
| 908 | public function getLowerExpression($str) |
||
| 912 | |||
| 913 | /** |
||
| 914 | * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. |
||
| 915 | * |
||
| 916 | * @param string $str Literal string. |
||
| 917 | * @param string $substr Literal string to find. |
||
| 918 | * @param int|bool $startPos Position to start at, beginning of string by default. |
||
| 919 | * |
||
| 920 | * @return string |
||
| 921 | * |
||
| 922 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 923 | */ |
||
| 924 | public function getLocateExpression($str, $substr, $startPos = false) |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Returns the SQL snippet to get the current system date. |
||
| 931 | * |
||
| 932 | * @return string |
||
| 933 | */ |
||
| 934 | public function getNowExpression() |
||
| 938 | |||
| 939 | /** |
||
| 940 | * Returns a SQL snippet to get a substring inside an SQL statement. |
||
| 941 | * |
||
| 942 | * Note: Not SQL92, but common functionality. |
||
| 943 | * |
||
| 944 | * SQLite only supports the 2 parameter variant of this function. |
||
| 945 | * |
||
| 946 | * @param string $value An sql string literal or column name/alias. |
||
| 947 | * @param int $from Where to start the substring portion. |
||
| 948 | * @param int|null $length The substring portion length. |
||
| 949 | * |
||
| 950 | * @return string |
||
| 951 | */ |
||
| 952 | public function getSubstringExpression($value, $from, $length = null) |
||
| 960 | |||
| 961 | /** |
||
| 962 | * Returns a SQL snippet to concatenate the given expressions. |
||
| 963 | * |
||
| 964 | * Accepts an arbitrary number of string parameters. Each parameter must contain an expression. |
||
| 965 | * |
||
| 966 | * @return string |
||
| 967 | */ |
||
| 968 | public function getConcatExpression() |
||
| 972 | |||
| 973 | /** |
||
| 974 | * Returns the SQL for a logical not. |
||
| 975 | * |
||
| 976 | * Example: |
||
| 977 | * <code> |
||
| 978 | * $q = new Doctrine_Query(); |
||
| 979 | * $e = $q->expr; |
||
| 980 | * $q->select('*')->from('table') |
||
| 981 | * ->where($e->eq('id', $e->not('null')); |
||
| 982 | * </code> |
||
| 983 | * |
||
| 984 | * @param string $expression |
||
| 985 | * |
||
| 986 | * @return string The logical expression. |
||
| 987 | */ |
||
| 988 | public function getNotExpression($expression) |
||
| 992 | |||
| 993 | /** |
||
| 994 | * Returns the SQL that checks if an expression is null. |
||
| 995 | * |
||
| 996 | * @param string $expression The expression that should be compared to null. |
||
| 997 | * |
||
| 998 | * @return string The logical expression. |
||
| 999 | */ |
||
| 1000 | public function getIsNullExpression($expression) |
||
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Returns the SQL that checks if an expression is not null. |
||
| 1007 | * |
||
| 1008 | * @param string $expression The expression that should be compared to null. |
||
| 1009 | * |
||
| 1010 | * @return string The logical expression. |
||
| 1011 | */ |
||
| 1012 | public function getIsNotNullExpression($expression) |
||
| 1016 | |||
| 1017 | /** |
||
| 1018 | * Returns the SQL that checks if an expression evaluates to a value between two values. |
||
| 1019 | * |
||
| 1020 | * The parameter $expression is checked if it is between $value1 and $value2. |
||
| 1021 | * |
||
| 1022 | * Note: There is a slight difference in the way BETWEEN works on some databases. |
||
| 1023 | * http://www.w3schools.com/sql/sql_between.asp. If you want complete database |
||
| 1024 | * independence you should avoid using between(). |
||
| 1025 | * |
||
| 1026 | * @param string $expression The value to compare to. |
||
| 1027 | * @param string $value1 The lower value to compare with. |
||
| 1028 | * @param string $value2 The higher value to compare with. |
||
| 1029 | * |
||
| 1030 | * @return string The logical expression. |
||
| 1031 | */ |
||
| 1032 | public function getBetweenExpression($expression, $value1, $value2) |
||
| 1036 | |||
| 1037 | /** |
||
| 1038 | * Returns the SQL to get the arccosine of a value. |
||
| 1039 | * |
||
| 1040 | * @param string $value |
||
| 1041 | * |
||
| 1042 | * @return string |
||
| 1043 | */ |
||
| 1044 | public function getAcosExpression($value) |
||
| 1048 | |||
| 1049 | /** |
||
| 1050 | * Returns the SQL to get the sine of a value. |
||
| 1051 | * |
||
| 1052 | * @param string $value |
||
| 1053 | * |
||
| 1054 | * @return string |
||
| 1055 | */ |
||
| 1056 | public function getSinExpression($value) |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Returns the SQL to get the PI value. |
||
| 1063 | * |
||
| 1064 | * @return string |
||
| 1065 | */ |
||
| 1066 | public function getPiExpression() |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Returns the SQL to get the cosine of a value. |
||
| 1073 | * |
||
| 1074 | * @param string $value |
||
| 1075 | * |
||
| 1076 | * @return string |
||
| 1077 | */ |
||
| 1078 | public function getCosExpression($value) |
||
| 1082 | |||
| 1083 | /** |
||
| 1084 | * Returns the SQL to calculate the difference in days between the two passed dates. |
||
| 1085 | * |
||
| 1086 | * Computes diff = date1 - date2. |
||
| 1087 | * |
||
| 1088 | * @param string $date1 |
||
| 1089 | * @param string $date2 |
||
| 1090 | * |
||
| 1091 | * @return string |
||
| 1092 | * |
||
| 1093 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1094 | */ |
||
| 1095 | public function getDateDiffExpression($date1, $date2) |
||
| 1099 | |||
| 1100 | /** |
||
| 1101 | * Returns the SQL to add the number of given seconds to a date. |
||
| 1102 | * |
||
| 1103 | * @param string $date |
||
| 1104 | * @param int $seconds |
||
| 1105 | * |
||
| 1106 | * @return string |
||
| 1107 | * |
||
| 1108 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1109 | */ |
||
| 1110 | public function getDateAddSecondsExpression($date, $seconds) |
||
| 1114 | |||
| 1115 | /** |
||
| 1116 | * Returns the SQL to subtract the number of given seconds from a date. |
||
| 1117 | * |
||
| 1118 | * @param string $date |
||
| 1119 | * @param int $seconds |
||
| 1120 | * |
||
| 1121 | * @return string |
||
| 1122 | * |
||
| 1123 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1124 | */ |
||
| 1125 | public function getDateSubSecondsExpression($date, $seconds) |
||
| 1129 | |||
| 1130 | /** |
||
| 1131 | * Returns the SQL to add the number of given minutes to a date. |
||
| 1132 | * |
||
| 1133 | * @param string $date |
||
| 1134 | * @param int $minutes |
||
| 1135 | * |
||
| 1136 | * @return string |
||
| 1137 | * |
||
| 1138 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1139 | */ |
||
| 1140 | public function getDateAddMinutesExpression($date, $minutes) |
||
| 1144 | |||
| 1145 | /** |
||
| 1146 | * Returns the SQL to subtract the number of given minutes from a date. |
||
| 1147 | * |
||
| 1148 | * @param string $date |
||
| 1149 | * @param int $minutes |
||
| 1150 | * |
||
| 1151 | * @return string |
||
| 1152 | * |
||
| 1153 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1154 | */ |
||
| 1155 | public function getDateSubMinutesExpression($date, $minutes) |
||
| 1159 | |||
| 1160 | /** |
||
| 1161 | * Returns the SQL to add the number of given hours to a date. |
||
| 1162 | * |
||
| 1163 | * @param string $date |
||
| 1164 | * @param int $hours |
||
| 1165 | * |
||
| 1166 | * @return string |
||
| 1167 | * |
||
| 1168 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1169 | */ |
||
| 1170 | public function getDateAddHourExpression($date, $hours) |
||
| 1174 | |||
| 1175 | /** |
||
| 1176 | * Returns the SQL to subtract the number of given hours to a date. |
||
| 1177 | * |
||
| 1178 | * @param string $date |
||
| 1179 | * @param int $hours |
||
| 1180 | * |
||
| 1181 | * @return string |
||
| 1182 | * |
||
| 1183 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1184 | */ |
||
| 1185 | public function getDateSubHourExpression($date, $hours) |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Returns the SQL to add the number of given days to a date. |
||
| 1192 | * |
||
| 1193 | * @param string $date |
||
| 1194 | * @param int $days |
||
| 1195 | * |
||
| 1196 | * @return string |
||
| 1197 | * |
||
| 1198 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1199 | */ |
||
| 1200 | public function getDateAddDaysExpression($date, $days) |
||
| 1204 | |||
| 1205 | /** |
||
| 1206 | * Returns the SQL to subtract the number of given days to a date. |
||
| 1207 | * |
||
| 1208 | * @param string $date |
||
| 1209 | * @param int $days |
||
| 1210 | * |
||
| 1211 | * @return string |
||
| 1212 | * |
||
| 1213 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1214 | */ |
||
| 1215 | public function getDateSubDaysExpression($date, $days) |
||
| 1219 | |||
| 1220 | /** |
||
| 1221 | * Returns the SQL to add the number of given weeks to a date. |
||
| 1222 | * |
||
| 1223 | * @param string $date |
||
| 1224 | * @param int $weeks |
||
| 1225 | * |
||
| 1226 | * @return string |
||
| 1227 | * |
||
| 1228 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1229 | */ |
||
| 1230 | public function getDateAddWeeksExpression($date, $weeks) |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Returns the SQL to subtract the number of given weeks from a date. |
||
| 1237 | * |
||
| 1238 | * @param string $date |
||
| 1239 | * @param int $weeks |
||
| 1240 | * |
||
| 1241 | * @return string |
||
| 1242 | * |
||
| 1243 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1244 | */ |
||
| 1245 | public function getDateSubWeeksExpression($date, $weeks) |
||
| 1249 | |||
| 1250 | /** |
||
| 1251 | * Returns the SQL to add the number of given months to a date. |
||
| 1252 | * |
||
| 1253 | * @param string $date |
||
| 1254 | * @param int $months |
||
| 1255 | * |
||
| 1256 | * @return string |
||
| 1257 | * |
||
| 1258 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1259 | */ |
||
| 1260 | public function getDateAddMonthExpression($date, $months) |
||
| 1264 | |||
| 1265 | /** |
||
| 1266 | * Returns the SQL to subtract the number of given months to a date. |
||
| 1267 | * |
||
| 1268 | * @param string $date |
||
| 1269 | * @param int $months |
||
| 1270 | * |
||
| 1271 | * @return string |
||
| 1272 | * |
||
| 1273 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1274 | */ |
||
| 1275 | public function getDateSubMonthExpression($date, $months) |
||
| 1279 | |||
| 1280 | /** |
||
| 1281 | * Returns the SQL to add the number of given quarters to a date. |
||
| 1282 | * |
||
| 1283 | * @param string $date |
||
| 1284 | * @param int $quarters |
||
| 1285 | * |
||
| 1286 | * @return string |
||
| 1287 | * |
||
| 1288 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1289 | */ |
||
| 1290 | public function getDateAddQuartersExpression($date, $quarters) |
||
| 1294 | |||
| 1295 | /** |
||
| 1296 | * Returns the SQL to subtract the number of given quarters from a date. |
||
| 1297 | * |
||
| 1298 | * @param string $date |
||
| 1299 | * @param int $quarters |
||
| 1300 | * |
||
| 1301 | * @return string |
||
| 1302 | * |
||
| 1303 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1304 | */ |
||
| 1305 | public function getDateSubQuartersExpression($date, $quarters) |
||
| 1309 | |||
| 1310 | /** |
||
| 1311 | * Returns the SQL to add the number of given years to a date. |
||
| 1312 | * |
||
| 1313 | * @param string $date |
||
| 1314 | * @param int $years |
||
| 1315 | * |
||
| 1316 | * @return string |
||
| 1317 | * |
||
| 1318 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1319 | */ |
||
| 1320 | public function getDateAddYearsExpression($date, $years) |
||
| 1324 | |||
| 1325 | /** |
||
| 1326 | * Returns the SQL to subtract the number of given years from a date. |
||
| 1327 | * |
||
| 1328 | * @param string $date |
||
| 1329 | * @param int $years |
||
| 1330 | * |
||
| 1331 | * @return string |
||
| 1332 | * |
||
| 1333 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1334 | */ |
||
| 1335 | public function getDateSubYearsExpression($date, $years) |
||
| 1339 | |||
| 1340 | /** |
||
| 1341 | * Returns the SQL for a date arithmetic expression. |
||
| 1342 | * |
||
| 1343 | * @param string $date The column or literal representing a date to perform the arithmetic operation on. |
||
| 1344 | * @param string $operator The arithmetic operator (+ or -). |
||
| 1345 | * @param int $interval The interval that shall be calculated into the date. |
||
| 1346 | * @param string $unit The unit of the interval that shall be calculated into the date. |
||
| 1347 | * One of the DATE_INTERVAL_UNIT_* constants. |
||
| 1348 | * |
||
| 1349 | * @return string |
||
| 1350 | * |
||
| 1351 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1352 | */ |
||
| 1353 | protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) |
||
| 1357 | |||
| 1358 | /** |
||
| 1359 | * Returns the SQL bit AND comparison expression. |
||
| 1360 | * |
||
| 1361 | * @param string $value1 |
||
| 1362 | * @param string $value2 |
||
| 1363 | * |
||
| 1364 | * @return string |
||
| 1365 | */ |
||
| 1366 | public function getBitAndComparisonExpression($value1, $value2) |
||
| 1370 | |||
| 1371 | /** |
||
| 1372 | * Returns the SQL bit OR comparison expression. |
||
| 1373 | * |
||
| 1374 | * @param string $value1 |
||
| 1375 | * @param string $value2 |
||
| 1376 | * |
||
| 1377 | * @return string |
||
| 1378 | */ |
||
| 1379 | public function getBitOrComparisonExpression($value1, $value2) |
||
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Returns the FOR UPDATE expression. |
||
| 1386 | * |
||
| 1387 | * @return string |
||
| 1388 | */ |
||
| 1389 | public function getForUpdateSQL() |
||
| 1393 | |||
| 1394 | /** |
||
| 1395 | * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. |
||
| 1396 | * |
||
| 1397 | * @param string $fromClause The FROM clause to append the hint for the given lock mode to. |
||
| 1398 | * @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will |
||
| 1399 | * be appended to the FROM clause. |
||
| 1400 | * |
||
| 1401 | * @return string |
||
| 1402 | */ |
||
| 1403 | public function appendLockHint($fromClause, $lockMode) |
||
| 1407 | |||
| 1408 | /** |
||
| 1409 | * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock. |
||
| 1410 | * |
||
| 1411 | * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database |
||
| 1412 | * vendors allow to lighten this constraint up to be a real read lock. |
||
| 1413 | * |
||
| 1414 | * @return string |
||
| 1415 | */ |
||
| 1416 | public function getReadLockSQL() |
||
| 1420 | |||
| 1421 | /** |
||
| 1422 | * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. |
||
| 1423 | * |
||
| 1424 | * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard. |
||
| 1425 | * |
||
| 1426 | * @return string |
||
| 1427 | */ |
||
| 1428 | public function getWriteLockSQL() |
||
| 1432 | |||
| 1433 | /** |
||
| 1434 | * Returns the SQL snippet to drop an existing database. |
||
| 1435 | * |
||
| 1436 | * @param string $database The name of the database that should be dropped. |
||
| 1437 | * |
||
| 1438 | * @return string |
||
| 1439 | */ |
||
| 1440 | public function getDropDatabaseSQL($database) |
||
| 1444 | |||
| 1445 | /** |
||
| 1446 | * Returns the SQL snippet to drop an existing table. |
||
| 1447 | * |
||
| 1448 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1449 | * |
||
| 1450 | * @return string |
||
| 1451 | * |
||
| 1452 | * @throws \InvalidArgumentException |
||
| 1453 | */ |
||
| 1454 | public function getDropTableSQL($table) |
||
| 1475 | |||
| 1476 | /** |
||
| 1477 | * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. |
||
| 1478 | * |
||
| 1479 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1480 | * |
||
| 1481 | * @return string |
||
| 1482 | */ |
||
| 1483 | public function getDropTemporaryTableSQL($table) |
||
| 1487 | |||
| 1488 | /** |
||
| 1489 | * Returns the SQL to drop an index from a table. |
||
| 1490 | * |
||
| 1491 | * @param \Doctrine\DBAL\Schema\Index|string $index |
||
| 1492 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1493 | * |
||
| 1494 | * @return string |
||
| 1495 | * |
||
| 1496 | * @throws \InvalidArgumentException |
||
| 1497 | */ |
||
| 1498 | public function getDropIndexSQL($index, $table = null) |
||
| 1508 | |||
| 1509 | /** |
||
| 1510 | * Returns the SQL to drop a constraint. |
||
| 1511 | * |
||
| 1512 | * @param \Doctrine\DBAL\Schema\Constraint|string $constraint |
||
| 1513 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1514 | * |
||
| 1515 | * @return string |
||
| 1516 | */ |
||
| 1517 | public function getDropConstraintSQL($constraint, $table) |
||
| 1532 | |||
| 1533 | /** |
||
| 1534 | * Returns the SQL to drop a foreign key. |
||
| 1535 | * |
||
| 1536 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint|string $foreignKey |
||
| 1537 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1538 | * |
||
| 1539 | * @return string |
||
| 1540 | */ |
||
| 1541 | public function getDropForeignKeySQL($foreignKey, $table) |
||
| 1556 | |||
| 1557 | /** |
||
| 1558 | * Returns the SQL statement(s) to create a table with the specified name, columns and constraints |
||
| 1559 | * on this platform. |
||
| 1560 | * |
||
| 1561 | * @param \Doctrine\DBAL\Schema\Table $table |
||
| 1562 | * @param int $createFlags |
||
| 1563 | * |
||
| 1564 | * @return array The sequence of SQL statements. |
||
| 1565 | * |
||
| 1566 | * @throws \Doctrine\DBAL\DBALException |
||
| 1567 | * @throws \InvalidArgumentException |
||
| 1568 | */ |
||
| 1569 | public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) |
||
| 1659 | |||
| 1660 | /** |
||
| 1661 | * @param string $tableName |
||
| 1662 | * @param string $columnName |
||
| 1663 | * @param string $comment |
||
| 1664 | * |
||
| 1665 | * @return string |
||
| 1666 | */ |
||
| 1667 | public function getCommentOnColumnSQL($tableName, $columnName, $comment) |
||
| 1676 | |||
| 1677 | /** |
||
| 1678 | * Returns the SQL to create inline comment on a column. |
||
| 1679 | * |
||
| 1680 | * @param string $comment |
||
| 1681 | * |
||
| 1682 | * @return string |
||
| 1683 | * |
||
| 1684 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1685 | */ |
||
| 1686 | public function getInlineColumnCommentSQL($comment) |
||
| 1694 | |||
| 1695 | /** |
||
| 1696 | * Returns the SQL used to create a table. |
||
| 1697 | * |
||
| 1698 | * @param string $tableName |
||
| 1699 | * @param array $columns |
||
| 1700 | * @param array $options |
||
| 1701 | * |
||
| 1702 | * @return array |
||
| 1703 | */ |
||
| 1704 | protected function _getCreateTableSQL($tableName, array $columns, array $options = []) |
||
| 1742 | |||
| 1743 | /** |
||
| 1744 | * @return string |
||
| 1745 | */ |
||
| 1746 | public function getCreateTemporaryTableSnippetSQL() |
||
| 1750 | |||
| 1751 | /** |
||
| 1752 | * Returns the SQL to create a sequence on this platform. |
||
| 1753 | * |
||
| 1754 | * @param \Doctrine\DBAL\Schema\Sequence $sequence |
||
| 1755 | * |
||
| 1756 | * @return string |
||
| 1757 | * |
||
| 1758 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1759 | */ |
||
| 1760 | public function getCreateSequenceSQL(Sequence $sequence) |
||
| 1764 | |||
| 1765 | /** |
||
| 1766 | * Returns the SQL to change a sequence on this platform. |
||
| 1767 | * |
||
| 1768 | * @param \Doctrine\DBAL\Schema\Sequence $sequence |
||
| 1769 | * |
||
| 1770 | * @return string |
||
| 1771 | * |
||
| 1772 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1773 | */ |
||
| 1774 | public function getAlterSequenceSQL(Sequence $sequence) |
||
| 1778 | |||
| 1779 | /** |
||
| 1780 | * Returns the SQL to create a constraint on a table on this platform. |
||
| 1781 | * |
||
| 1782 | * @param \Doctrine\DBAL\Schema\Constraint $constraint |
||
| 1783 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1784 | * |
||
| 1785 | * @return string |
||
| 1786 | * |
||
| 1787 | * @throws \InvalidArgumentException |
||
| 1788 | */ |
||
| 1789 | public function getCreateConstraintSQL(Constraint $constraint, $table) |
||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * Returns the SQL to create an index on a table on this platform. |
||
| 1823 | * |
||
| 1824 | * @param \Doctrine\DBAL\Schema\Index $index |
||
| 1825 | * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created. |
||
| 1826 | * |
||
| 1827 | * @return string |
||
| 1828 | * |
||
| 1829 | * @throws \InvalidArgumentException |
||
| 1830 | */ |
||
| 1831 | public function getCreateIndexSQL(Index $index, $table) |
||
| 1852 | |||
| 1853 | /** |
||
| 1854 | * Adds condition for partial index. |
||
| 1855 | * |
||
| 1856 | * @param \Doctrine\DBAL\Schema\Index $index |
||
| 1857 | * |
||
| 1858 | * @return string |
||
| 1859 | */ |
||
| 1860 | protected function getPartialIndexSQL(Index $index) |
||
| 1868 | |||
| 1869 | /** |
||
| 1870 | * Adds additional flags for index generation. |
||
| 1871 | * |
||
| 1872 | * @param \Doctrine\DBAL\Schema\Index $index |
||
| 1873 | * |
||
| 1874 | * @return string |
||
| 1875 | */ |
||
| 1876 | protected function getCreateIndexSQLFlags(Index $index) |
||
| 1880 | |||
| 1881 | /** |
||
| 1882 | * Returns the SQL to create an unnamed primary key constraint. |
||
| 1883 | * |
||
| 1884 | * @param \Doctrine\DBAL\Schema\Index $index |
||
| 1885 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
| 1886 | * |
||
| 1887 | * @return string |
||
| 1888 | */ |
||
| 1889 | public function getCreatePrimaryKeySQL(Index $index, $table) |
||
| 1893 | |||
| 1894 | /** |
||
| 1895 | * Returns the SQL to create a named schema. |
||
| 1896 | * |
||
| 1897 | * @param string $schemaName |
||
| 1898 | * |
||
| 1899 | * @return string |
||
| 1900 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1901 | */ |
||
| 1902 | public function getCreateSchemaSQL($schemaName) |
||
| 1906 | |||
| 1907 | /** |
||
| 1908 | * Quotes a string so that it can be safely used as a table or column name, |
||
| 1909 | * even if it is a reserved word of the platform. This also detects identifier |
||
| 1910 | * chains separated by dot and quotes them independently. |
||
| 1911 | * |
||
| 1912 | * NOTE: Just because you CAN use quoted identifiers doesn't mean |
||
| 1913 | * you SHOULD use them. In general, they end up causing way more |
||
| 1914 | * problems than they solve. |
||
| 1915 | * |
||
| 1916 | * @param string $str The identifier name to be quoted. |
||
| 1917 | * |
||
| 1918 | * @return string The quoted identifier string. |
||
| 1919 | */ |
||
| 1920 | public function quoteIdentifier($str) |
||
| 1930 | |||
| 1931 | /** |
||
| 1932 | * Quotes a single identifier (no dot chain separation). |
||
| 1933 | * |
||
| 1934 | * @param string $str The identifier name to be quoted. |
||
| 1935 | * |
||
| 1936 | * @return string The quoted identifier string. |
||
| 1937 | */ |
||
| 1938 | public function quoteSingleIdentifier($str) |
||
| 1944 | |||
| 1945 | /** |
||
| 1946 | * Returns the SQL to create a new foreign key. |
||
| 1947 | * |
||
| 1948 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key constraint. |
||
| 1949 | * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the foreign key is to be created. |
||
| 1950 | * |
||
| 1951 | * @return string |
||
| 1952 | */ |
||
| 1953 | public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) |
||
| 1963 | |||
| 1964 | /** |
||
| 1965 | * Gets the SQL statements for altering an existing table. |
||
| 1966 | * |
||
| 1967 | * This method returns an array of SQL statements, since some platforms need several statements. |
||
| 1968 | * |
||
| 1969 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 1970 | * |
||
| 1971 | * @return array |
||
| 1972 | * |
||
| 1973 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 1974 | */ |
||
| 1975 | public function getAlterTableSQL(TableDiff $diff) |
||
| 1979 | |||
| 1980 | /** |
||
| 1981 | * @param \Doctrine\DBAL\Schema\Column $column |
||
| 1982 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 1983 | * @param array $columnSql |
||
| 1984 | * |
||
| 1985 | * @return bool |
||
| 1986 | */ |
||
| 1987 | protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, &$columnSql) |
||
| 2004 | |||
| 2005 | /** |
||
| 2006 | * @param \Doctrine\DBAL\Schema\Column $column |
||
| 2007 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2008 | * @param array $columnSql |
||
| 2009 | * |
||
| 2010 | * @return bool |
||
| 2011 | */ |
||
| 2012 | protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, &$columnSql) |
||
| 2029 | |||
| 2030 | /** |
||
| 2031 | * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff |
||
| 2032 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2033 | * @param array $columnSql |
||
| 2034 | * |
||
| 2035 | * @return bool |
||
| 2036 | */ |
||
| 2037 | protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, &$columnSql) |
||
| 2054 | |||
| 2055 | /** |
||
| 2056 | * @param string $oldColumnName |
||
| 2057 | * @param \Doctrine\DBAL\Schema\Column $column |
||
| 2058 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2059 | * @param array $columnSql |
||
| 2060 | * |
||
| 2061 | * @return bool |
||
| 2062 | */ |
||
| 2063 | protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column, TableDiff $diff, &$columnSql) |
||
| 2080 | |||
| 2081 | /** |
||
| 2082 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2083 | * @param array $sql |
||
| 2084 | * |
||
| 2085 | * @return bool |
||
| 2086 | */ |
||
| 2087 | protected function onSchemaAlterTable(TableDiff $diff, &$sql) |
||
| 2104 | |||
| 2105 | /** |
||
| 2106 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2107 | * |
||
| 2108 | * @return array |
||
| 2109 | */ |
||
| 2110 | protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
| 2133 | |||
| 2134 | /** |
||
| 2135 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2136 | * |
||
| 2137 | * @return array |
||
| 2138 | */ |
||
| 2139 | protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
| 2175 | |||
| 2176 | /** |
||
| 2177 | * Returns the SQL for renaming an index on a table. |
||
| 2178 | * |
||
| 2179 | * @param string $oldIndexName The name of the index to rename from. |
||
| 2180 | * @param \Doctrine\DBAL\Schema\Index $index The definition of the index to rename to. |
||
| 2181 | * @param string $tableName The table to rename the given index on. |
||
| 2182 | * |
||
| 2183 | * @return array The sequence of SQL statements for renaming the given index. |
||
| 2184 | */ |
||
| 2185 | protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) |
||
| 2192 | |||
| 2193 | /** |
||
| 2194 | * Common code for alter table statement generation that updates the changed Index and Foreign Key definitions. |
||
| 2195 | * |
||
| 2196 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
| 2197 | * |
||
| 2198 | * @return array |
||
| 2199 | */ |
||
| 2200 | protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
| 2204 | |||
| 2205 | /** |
||
| 2206 | * Gets declaration of a number of fields in bulk. |
||
| 2207 | * |
||
| 2208 | * @param array $fields A multidimensional associative array. |
||
| 2209 | * The first dimension determines the field name, while the second |
||
| 2210 | * dimension is keyed with the name of the properties |
||
| 2211 | * of the field being declared as array indexes. Currently, the types |
||
| 2212 | * of supported field properties are as follows: |
||
| 2213 | * |
||
| 2214 | * length |
||
| 2215 | * Integer value that determines the maximum length of the text |
||
| 2216 | * field. If this argument is missing the field should be |
||
| 2217 | * declared to have the longest length allowed by the DBMS. |
||
| 2218 | * |
||
| 2219 | * default |
||
| 2220 | * Text value to be used as default for this field. |
||
| 2221 | * |
||
| 2222 | * notnull |
||
| 2223 | * Boolean flag that indicates whether this field is constrained |
||
| 2224 | * to not be set to null. |
||
| 2225 | * charset |
||
| 2226 | * Text value with the default CHARACTER SET for this field. |
||
| 2227 | * collation |
||
| 2228 | * Text value with the default COLLATION for this field. |
||
| 2229 | * unique |
||
| 2230 | * unique constraint |
||
| 2231 | * |
||
| 2232 | * @return string |
||
| 2233 | */ |
||
| 2234 | public function getColumnDeclarationListSQL(array $fields) |
||
| 2244 | |||
| 2245 | /** |
||
| 2246 | * Obtains DBMS specific SQL code portion needed to declare a generic type |
||
| 2247 | * field to be used in statements like CREATE TABLE. |
||
| 2248 | * |
||
| 2249 | * @param string $name The name the field to be declared. |
||
| 2250 | * @param array $field An associative array with the name of the properties |
||
| 2251 | * of the field being declared as array indexes. Currently, the types |
||
| 2252 | * of supported field properties are as follows: |
||
| 2253 | * |
||
| 2254 | * length |
||
| 2255 | * Integer value that determines the maximum length of the text |
||
| 2256 | * field. If this argument is missing the field should be |
||
| 2257 | * declared to have the longest length allowed by the DBMS. |
||
| 2258 | * |
||
| 2259 | * default |
||
| 2260 | * Text value to be used as default for this field. |
||
| 2261 | * |
||
| 2262 | * notnull |
||
| 2263 | * Boolean flag that indicates whether this field is constrained |
||
| 2264 | * to not be set to null. |
||
| 2265 | * charset |
||
| 2266 | * Text value with the default CHARACTER SET for this field. |
||
| 2267 | * collation |
||
| 2268 | * Text value with the default COLLATION for this field. |
||
| 2269 | * unique |
||
| 2270 | * unique constraint |
||
| 2271 | * check |
||
| 2272 | * column check constraint |
||
| 2273 | * columnDefinition |
||
| 2274 | * a string that defines the complete column |
||
| 2275 | * |
||
| 2276 | * @return string DBMS specific SQL code portion that should be used to declare the column. |
||
| 2277 | */ |
||
| 2278 | public function getColumnDeclarationSQL($name, array $field) |
||
| 2309 | |||
| 2310 | /** |
||
| 2311 | * Returns the SQL snippet that declares a floating point column of arbitrary precision. |
||
| 2312 | * |
||
| 2313 | * @param array $columnDef |
||
| 2314 | * |
||
| 2315 | * @return string |
||
| 2316 | */ |
||
| 2317 | public function getDecimalTypeDeclarationSQL(array $columnDef) |
||
| 2326 | |||
| 2327 | /** |
||
| 2328 | * Obtains DBMS specific SQL code portion needed to set a default value |
||
| 2329 | * declaration to be used in statements like CREATE TABLE. |
||
| 2330 | * |
||
| 2331 | * @param array $field The field definition array. |
||
| 2332 | * |
||
| 2333 | * @return string DBMS specific SQL code portion needed to set a default value. |
||
| 2334 | */ |
||
| 2335 | public function getDefaultValueDeclarationSQL($field) |
||
| 2371 | |||
| 2372 | /** |
||
| 2373 | * Obtains DBMS specific SQL code portion needed to set a CHECK constraint |
||
| 2374 | * declaration to be used in statements like CREATE TABLE. |
||
| 2375 | * |
||
| 2376 | * @param array $definition The check definition. |
||
| 2377 | * |
||
| 2378 | * @return string DBMS specific SQL code portion needed to set a CHECK constraint. |
||
| 2379 | */ |
||
| 2380 | public function getCheckDeclarationSQL(array $definition) |
||
| 2399 | |||
| 2400 | /** |
||
| 2401 | * Obtains DBMS specific SQL code portion needed to set a unique |
||
| 2402 | * constraint declaration to be used in statements like CREATE TABLE. |
||
| 2403 | * |
||
| 2404 | * @param string $name The name of the unique constraint. |
||
| 2405 | * @param \Doctrine\DBAL\Schema\Index $index The index definition. |
||
| 2406 | * |
||
| 2407 | * @return string DBMS specific SQL code portion needed to set a constraint. |
||
| 2408 | * |
||
| 2409 | * @throws \InvalidArgumentException |
||
| 2410 | */ |
||
| 2411 | public function getUniqueConstraintDeclarationSQL($name, Index $index) |
||
| 2424 | |||
| 2425 | /** |
||
| 2426 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2427 | * declaration to be used in statements like CREATE TABLE. |
||
| 2428 | * |
||
| 2429 | * @param string $name The name of the index. |
||
| 2430 | * @param \Doctrine\DBAL\Schema\Index $index The index definition. |
||
| 2431 | * |
||
| 2432 | * @return string DBMS specific SQL code portion needed to set an index. |
||
| 2433 | * |
||
| 2434 | * @throws \InvalidArgumentException |
||
| 2435 | */ |
||
| 2436 | public function getIndexDeclarationSQL($name, Index $index) |
||
| 2449 | |||
| 2450 | /** |
||
| 2451 | * Obtains SQL code portion needed to create a custom column, |
||
| 2452 | * e.g. when a field has the "columnDefinition" keyword. |
||
| 2453 | * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate. |
||
| 2454 | * |
||
| 2455 | * @param array $columnDef |
||
| 2456 | * |
||
| 2457 | * @return string |
||
| 2458 | */ |
||
| 2459 | public function getCustomTypeDeclarationSQL(array $columnDef) |
||
| 2463 | |||
| 2464 | /** |
||
| 2465 | * Obtains DBMS specific SQL code portion needed to set an index |
||
| 2466 | * declaration to be used in statements like CREATE TABLE. |
||
| 2467 | * |
||
| 2468 | * @param array $fields |
||
| 2469 | * |
||
| 2470 | * @return string |
||
| 2471 | */ |
||
| 2472 | public function getIndexFieldDeclarationListSQL(array $fields) |
||
| 2486 | |||
| 2487 | /** |
||
| 2488 | * Returns the required SQL string that fits between CREATE ... TABLE |
||
| 2489 | * to create the table as a temporary table. |
||
| 2490 | * |
||
| 2491 | * Should be overridden in driver classes to return the correct string for the |
||
| 2492 | * specific database type. |
||
| 2493 | * |
||
| 2494 | * The default is to return the string "TEMPORARY" - this will result in a |
||
| 2495 | * SQL error for any database that does not support temporary tables, or that |
||
| 2496 | * requires a different SQL command from "CREATE TEMPORARY TABLE". |
||
| 2497 | * |
||
| 2498 | * @return string The string required to be placed between "CREATE" and "TABLE" |
||
| 2499 | * to generate a temporary table, if possible. |
||
| 2500 | */ |
||
| 2501 | public function getTemporaryTableSQL() |
||
| 2505 | |||
| 2506 | /** |
||
| 2507 | * Some vendors require temporary table names to be qualified specially. |
||
| 2508 | * |
||
| 2509 | * @param string $tableName |
||
| 2510 | * |
||
| 2511 | * @return string |
||
| 2512 | */ |
||
| 2513 | public function getTemporaryTableName($tableName) |
||
| 2517 | |||
| 2518 | /** |
||
| 2519 | * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2520 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2521 | * |
||
| 2522 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey |
||
| 2523 | * |
||
| 2524 | * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2525 | * of a field declaration. |
||
| 2526 | */ |
||
| 2527 | public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) |
||
| 2534 | |||
| 2535 | /** |
||
| 2536 | * Returns the FOREIGN KEY query section dealing with non-standard options |
||
| 2537 | * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... |
||
| 2538 | * |
||
| 2539 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key definition. |
||
| 2540 | * |
||
| 2541 | * @return string |
||
| 2542 | */ |
||
| 2543 | public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) |
||
| 2555 | |||
| 2556 | /** |
||
| 2557 | * Returns the given referential action in uppercase if valid, otherwise throws an exception. |
||
| 2558 | * |
||
| 2559 | * @param string $action The foreign key referential action. |
||
| 2560 | * |
||
| 2561 | * @return string |
||
| 2562 | * |
||
| 2563 | * @throws \InvalidArgumentException if unknown referential action given |
||
| 2564 | */ |
||
| 2565 | public function getForeignKeyReferentialActionSQL($action) |
||
| 2579 | |||
| 2580 | /** |
||
| 2581 | * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
| 2582 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2583 | * |
||
| 2584 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey |
||
| 2585 | * |
||
| 2586 | * @return string |
||
| 2587 | * |
||
| 2588 | * @throws \InvalidArgumentException |
||
| 2589 | */ |
||
| 2590 | public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey) |
||
| 2615 | |||
| 2616 | /** |
||
| 2617 | * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2618 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2619 | * |
||
| 2620 | * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
| 2621 | * of a field declaration. |
||
| 2622 | */ |
||
| 2623 | public function getUniqueFieldDeclarationSQL() |
||
| 2627 | |||
| 2628 | /** |
||
| 2629 | * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2630 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2631 | * |
||
| 2632 | * @param string $charset The name of the charset. |
||
| 2633 | * |
||
| 2634 | * @return string DBMS specific SQL code portion needed to set the CHARACTER SET |
||
| 2635 | * of a field declaration. |
||
| 2636 | */ |
||
| 2637 | public function getColumnCharsetDeclarationSQL($charset) |
||
| 2641 | |||
| 2642 | /** |
||
| 2643 | * Obtains DBMS specific SQL code portion needed to set the COLLATION |
||
| 2644 | * of a field declaration to be used in statements like CREATE TABLE. |
||
| 2645 | * |
||
| 2646 | * @param string $collation The name of the collation. |
||
| 2647 | * |
||
| 2648 | * @return string DBMS specific SQL code portion needed to set the COLLATION |
||
| 2649 | * of a field declaration. |
||
| 2650 | */ |
||
| 2651 | public function getColumnCollationDeclarationSQL($collation) |
||
| 2655 | |||
| 2656 | /** |
||
| 2657 | * Whether the platform prefers sequences for ID generation. |
||
| 2658 | * Subclasses should override this method to return TRUE if they prefer sequences. |
||
| 2659 | * |
||
| 2660 | * @return bool |
||
| 2661 | */ |
||
| 2662 | public function prefersSequences() |
||
| 2666 | |||
| 2667 | /** |
||
| 2668 | * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. |
||
| 2669 | * Subclasses should override this method to return TRUE if they prefer identity columns. |
||
| 2670 | * |
||
| 2671 | * @return bool |
||
| 2672 | */ |
||
| 2673 | public function prefersIdentityColumns() |
||
| 2677 | |||
| 2678 | /** |
||
| 2679 | * Some platforms need the boolean values to be converted. |
||
| 2680 | * |
||
| 2681 | * The default conversion in this implementation converts to integers (false => 0, true => 1). |
||
| 2682 | * |
||
| 2683 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2684 | * |
||
| 2685 | * There are two contexts when converting booleans: Literals and Prepared Statements. |
||
| 2686 | * This method should handle the literal case |
||
| 2687 | * |
||
| 2688 | * @param mixed $item A boolean or an array of them. |
||
| 2689 | * |
||
| 2690 | * @return mixed A boolean database value or an array of them. |
||
| 2691 | */ |
||
| 2692 | public function convertBooleans($item) |
||
| 2706 | |||
| 2707 | /** |
||
| 2708 | * Some platforms have boolean literals that needs to be correctly converted |
||
| 2709 | * |
||
| 2710 | * The default conversion tries to convert value into bool "(bool)$item" |
||
| 2711 | * |
||
| 2712 | * @param mixed $item |
||
| 2713 | * |
||
| 2714 | * @return bool|null |
||
| 2715 | */ |
||
| 2716 | public function convertFromBoolean($item) |
||
| 2720 | |||
| 2721 | /** |
||
| 2722 | * This method should handle the prepared statements case. When there is no |
||
| 2723 | * distinction, it's OK to use the same method. |
||
| 2724 | * |
||
| 2725 | * Note: if the input is not a boolean the original input might be returned. |
||
| 2726 | * |
||
| 2727 | * @param mixed $item A boolean or an array of them. |
||
| 2728 | * |
||
| 2729 | * @return mixed A boolean database value or an array of them. |
||
| 2730 | */ |
||
| 2731 | public function convertBooleansToDatabaseValue($item) |
||
| 2735 | |||
| 2736 | /** |
||
| 2737 | * Returns the SQL specific for the platform to get the current date. |
||
| 2738 | * |
||
| 2739 | * @return string |
||
| 2740 | */ |
||
| 2741 | public function getCurrentDateSQL() |
||
| 2745 | |||
| 2746 | /** |
||
| 2747 | * Returns the SQL specific for the platform to get the current time. |
||
| 2748 | * |
||
| 2749 | * @return string |
||
| 2750 | */ |
||
| 2751 | public function getCurrentTimeSQL() |
||
| 2755 | |||
| 2756 | /** |
||
| 2757 | * Returns the SQL specific for the platform to get the current timestamp |
||
| 2758 | * |
||
| 2759 | * @return string |
||
| 2760 | */ |
||
| 2761 | public function getCurrentTimestampSQL() |
||
| 2765 | |||
| 2766 | /** |
||
| 2767 | * Returns the SQL for a given transaction isolation level Connection constant. |
||
| 2768 | * |
||
| 2769 | * @param int $level |
||
| 2770 | * |
||
| 2771 | * @return string |
||
| 2772 | * |
||
| 2773 | * @throws \InvalidArgumentException |
||
| 2774 | */ |
||
| 2775 | protected function _getTransactionIsolationLevelSQL($level) |
||
| 2790 | |||
| 2791 | /** |
||
| 2792 | * @return string |
||
| 2793 | * |
||
| 2794 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2795 | */ |
||
| 2796 | public function getListDatabasesSQL() |
||
| 2800 | |||
| 2801 | /** |
||
| 2802 | * Returns the SQL statement for retrieving the namespaces defined in the database. |
||
| 2803 | * |
||
| 2804 | * @return string |
||
| 2805 | * |
||
| 2806 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2807 | */ |
||
| 2808 | public function getListNamespacesSQL() |
||
| 2812 | |||
| 2813 | /** |
||
| 2814 | * @param string $database |
||
| 2815 | * |
||
| 2816 | * @return string |
||
| 2817 | * |
||
| 2818 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2819 | */ |
||
| 2820 | public function getListSequencesSQL($database) |
||
| 2824 | |||
| 2825 | /** |
||
| 2826 | * @param string $table |
||
| 2827 | * |
||
| 2828 | * @return string |
||
| 2829 | * |
||
| 2830 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2831 | */ |
||
| 2832 | public function getListTableConstraintsSQL($table) |
||
| 2836 | |||
| 2837 | /** |
||
| 2838 | * @param string $table |
||
| 2839 | * @param string|null $database |
||
| 2840 | * |
||
| 2841 | * @return string |
||
| 2842 | * |
||
| 2843 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2844 | */ |
||
| 2845 | public function getListTableColumnsSQL($table, $database = null) |
||
| 2849 | |||
| 2850 | /** |
||
| 2851 | * @return string |
||
| 2852 | * |
||
| 2853 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2854 | */ |
||
| 2855 | public function getListTablesSQL() |
||
| 2859 | |||
| 2860 | /** |
||
| 2861 | * @return string |
||
| 2862 | * |
||
| 2863 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2864 | */ |
||
| 2865 | public function getListUsersSQL() |
||
| 2869 | |||
| 2870 | /** |
||
| 2871 | * Returns the SQL to list all views of a database or user. |
||
| 2872 | * |
||
| 2873 | * @param string $database |
||
| 2874 | * |
||
| 2875 | * @return string |
||
| 2876 | * |
||
| 2877 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2878 | */ |
||
| 2879 | public function getListViewsSQL($database) |
||
| 2883 | |||
| 2884 | /** |
||
| 2885 | * Returns the list of indexes for the current database. |
||
| 2886 | * |
||
| 2887 | * The current database parameter is optional but will always be passed |
||
| 2888 | * when using the SchemaManager API and is the database the given table is in. |
||
| 2889 | * |
||
| 2890 | * Attention: Some platforms only support currentDatabase when they |
||
| 2891 | * are connected with that database. Cross-database information schema |
||
| 2892 | * requests may be impossible. |
||
| 2893 | * |
||
| 2894 | * @param string $table |
||
| 2895 | * @param string $currentDatabase |
||
| 2896 | * |
||
| 2897 | * @return string |
||
| 2898 | * |
||
| 2899 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2900 | */ |
||
| 2901 | public function getListTableIndexesSQL($table, $currentDatabase = null) |
||
| 2905 | |||
| 2906 | /** |
||
| 2907 | * @param string $table |
||
| 2908 | * |
||
| 2909 | * @return string |
||
| 2910 | * |
||
| 2911 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2912 | */ |
||
| 2913 | public function getListTableForeignKeysSQL($table) |
||
| 2917 | |||
| 2918 | /** |
||
| 2919 | * @param string $name |
||
| 2920 | * @param string $sql |
||
| 2921 | * |
||
| 2922 | * @return string |
||
| 2923 | * |
||
| 2924 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2925 | */ |
||
| 2926 | public function getCreateViewSQL($name, $sql) |
||
| 2930 | |||
| 2931 | /** |
||
| 2932 | * @param string $name |
||
| 2933 | * |
||
| 2934 | * @return string |
||
| 2935 | * |
||
| 2936 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2937 | */ |
||
| 2938 | public function getDropViewSQL($name) |
||
| 2942 | |||
| 2943 | /** |
||
| 2944 | * Returns the SQL snippet to drop an existing sequence. |
||
| 2945 | * |
||
| 2946 | * @param Sequence|string $sequence |
||
| 2947 | * |
||
| 2948 | * @return string |
||
| 2949 | * |
||
| 2950 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2951 | */ |
||
| 2952 | public function getDropSequenceSQL($sequence) |
||
| 2956 | |||
| 2957 | /** |
||
| 2958 | * @param string $sequenceName |
||
| 2959 | * |
||
| 2960 | * @return string |
||
| 2961 | * |
||
| 2962 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2963 | */ |
||
| 2964 | public function getSequenceNextValSQL($sequenceName) |
||
| 2968 | |||
| 2969 | /** |
||
| 2970 | * Returns the SQL to create a new database. |
||
| 2971 | * |
||
| 2972 | * @param string $database The name of the database that should be created. |
||
| 2973 | * |
||
| 2974 | * @return string |
||
| 2975 | * |
||
| 2976 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2977 | */ |
||
| 2978 | public function getCreateDatabaseSQL($database) |
||
| 2982 | |||
| 2983 | /** |
||
| 2984 | * Returns the SQL to set the transaction isolation level. |
||
| 2985 | * |
||
| 2986 | * @param int $level |
||
| 2987 | * |
||
| 2988 | * @return string |
||
| 2989 | * |
||
| 2990 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 2991 | */ |
||
| 2992 | public function getSetTransactionIsolationSQL($level) |
||
| 2996 | |||
| 2997 | /** |
||
| 2998 | * Obtains DBMS specific SQL to be used to create datetime fields in |
||
| 2999 | * statements like CREATE TABLE. |
||
| 3000 | * |
||
| 3001 | * @param array $fieldDeclaration |
||
| 3002 | * |
||
| 3003 | * @return string |
||
| 3004 | * |
||
| 3005 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3006 | */ |
||
| 3007 | public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3011 | |||
| 3012 | /** |
||
| 3013 | * Obtains DBMS specific SQL to be used to create datetime with timezone offset fields. |
||
| 3014 | * |
||
| 3015 | * @param array $fieldDeclaration |
||
| 3016 | * |
||
| 3017 | * @return string |
||
| 3018 | */ |
||
| 3019 | public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3023 | |||
| 3024 | |||
| 3025 | /** |
||
| 3026 | * Obtains DBMS specific SQL to be used to create date fields in statements |
||
| 3027 | * like CREATE TABLE. |
||
| 3028 | * |
||
| 3029 | * @param array $fieldDeclaration |
||
| 3030 | * |
||
| 3031 | * @return string |
||
| 3032 | * |
||
| 3033 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3034 | */ |
||
| 3035 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3039 | |||
| 3040 | /** |
||
| 3041 | * Obtains DBMS specific SQL to be used to create time fields in statements |
||
| 3042 | * like CREATE TABLE. |
||
| 3043 | * |
||
| 3044 | * @param array $fieldDeclaration |
||
| 3045 | * |
||
| 3046 | * @return string |
||
| 3047 | * |
||
| 3048 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3049 | */ |
||
| 3050 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
| 3054 | |||
| 3055 | /** |
||
| 3056 | * @param array $fieldDeclaration |
||
| 3057 | * |
||
| 3058 | * @return string |
||
| 3059 | */ |
||
| 3060 | public function getFloatDeclarationSQL(array $fieldDeclaration) |
||
| 3064 | |||
| 3065 | /** |
||
| 3066 | * Gets the default transaction isolation level of the platform. |
||
| 3067 | * |
||
| 3068 | * @return int The default isolation level. |
||
| 3069 | * |
||
| 3070 | * @see TransactionIsolationLevel |
||
| 3071 | */ |
||
| 3072 | public function getDefaultTransactionIsolationLevel() |
||
| 3076 | |||
| 3077 | /* supports*() methods */ |
||
| 3078 | |||
| 3079 | /** |
||
| 3080 | * Whether the platform supports sequences. |
||
| 3081 | * |
||
| 3082 | * @return bool |
||
| 3083 | */ |
||
| 3084 | public function supportsSequences() |
||
| 3088 | |||
| 3089 | /** |
||
| 3090 | * Whether the platform supports identity columns. |
||
| 3091 | * |
||
| 3092 | * Identity columns are columns that receive an auto-generated value from the |
||
| 3093 | * database on insert of a row. |
||
| 3094 | * |
||
| 3095 | * @return bool |
||
| 3096 | */ |
||
| 3097 | public function supportsIdentityColumns() |
||
| 3101 | |||
| 3102 | /** |
||
| 3103 | * Whether the platform emulates identity columns through sequences. |
||
| 3104 | * |
||
| 3105 | * Some platforms that do not support identity columns natively |
||
| 3106 | * but support sequences can emulate identity columns by using |
||
| 3107 | * sequences. |
||
| 3108 | * |
||
| 3109 | * @return bool |
||
| 3110 | */ |
||
| 3111 | public function usesSequenceEmulatedIdentityColumns() |
||
| 3115 | |||
| 3116 | /** |
||
| 3117 | * Returns the name of the sequence for a particular identity column in a particular table. |
||
| 3118 | * |
||
| 3119 | * @param string $tableName The name of the table to return the sequence name for. |
||
| 3120 | * @param string $columnName The name of the identity column in the table to return the sequence name for. |
||
| 3121 | * |
||
| 3122 | * @return string |
||
| 3123 | * |
||
| 3124 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3125 | * |
||
| 3126 | * @see usesSequenceEmulatedIdentityColumns |
||
| 3127 | */ |
||
| 3128 | public function getIdentitySequenceName($tableName, $columnName) |
||
| 3132 | |||
| 3133 | /** |
||
| 3134 | * Whether the platform supports indexes. |
||
| 3135 | * |
||
| 3136 | * @return bool |
||
| 3137 | */ |
||
| 3138 | public function supportsIndexes() |
||
| 3142 | |||
| 3143 | /** |
||
| 3144 | * Whether the platform supports partial indexes. |
||
| 3145 | * |
||
| 3146 | * @return bool |
||
| 3147 | */ |
||
| 3148 | public function supportsPartialIndexes() |
||
| 3152 | |||
| 3153 | /** |
||
| 3154 | * Whether the platform supports altering tables. |
||
| 3155 | * |
||
| 3156 | * @return bool |
||
| 3157 | */ |
||
| 3158 | public function supportsAlterTable() |
||
| 3162 | |||
| 3163 | /** |
||
| 3164 | * Whether the platform supports transactions. |
||
| 3165 | * |
||
| 3166 | * @return bool |
||
| 3167 | */ |
||
| 3168 | public function supportsTransactions() |
||
| 3172 | |||
| 3173 | /** |
||
| 3174 | * Whether the platform supports savepoints. |
||
| 3175 | * |
||
| 3176 | * @return bool |
||
| 3177 | */ |
||
| 3178 | public function supportsSavepoints() |
||
| 3182 | |||
| 3183 | /** |
||
| 3184 | * Whether the platform supports releasing savepoints. |
||
| 3185 | * |
||
| 3186 | * @return bool |
||
| 3187 | */ |
||
| 3188 | public function supportsReleaseSavepoints() |
||
| 3192 | |||
| 3193 | /** |
||
| 3194 | * Whether the platform supports primary key constraints. |
||
| 3195 | * |
||
| 3196 | * @return bool |
||
| 3197 | */ |
||
| 3198 | public function supportsPrimaryConstraints() |
||
| 3202 | |||
| 3203 | /** |
||
| 3204 | * Whether the platform supports foreign key constraints. |
||
| 3205 | * |
||
| 3206 | * @return bool |
||
| 3207 | */ |
||
| 3208 | public function supportsForeignKeyConstraints() |
||
| 3212 | |||
| 3213 | /** |
||
| 3214 | * Whether this platform supports onUpdate in foreign key constraints. |
||
| 3215 | * |
||
| 3216 | * @return bool |
||
| 3217 | */ |
||
| 3218 | public function supportsForeignKeyOnUpdate() |
||
| 3222 | |||
| 3223 | /** |
||
| 3224 | * Whether the platform supports database schemas. |
||
| 3225 | * |
||
| 3226 | * @return bool |
||
| 3227 | */ |
||
| 3228 | public function supportsSchemas() |
||
| 3232 | |||
| 3233 | /** |
||
| 3234 | * Whether this platform can emulate schemas. |
||
| 3235 | * |
||
| 3236 | * Platforms that either support or emulate schemas don't automatically |
||
| 3237 | * filter a schema for the namespaced elements in {@link |
||
| 3238 | * AbstractManager#createSchema}. |
||
| 3239 | * |
||
| 3240 | * @return bool |
||
| 3241 | */ |
||
| 3242 | public function canEmulateSchemas() |
||
| 3246 | |||
| 3247 | /** |
||
| 3248 | * Returns the default schema name. |
||
| 3249 | * |
||
| 3250 | * @return string |
||
| 3251 | * |
||
| 3252 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3253 | */ |
||
| 3254 | public function getDefaultSchemaName() |
||
| 3258 | |||
| 3259 | /** |
||
| 3260 | * Whether this platform supports create database. |
||
| 3261 | * |
||
| 3262 | * Some databases don't allow to create and drop databases at all or only with certain tools. |
||
| 3263 | * |
||
| 3264 | * @return bool |
||
| 3265 | */ |
||
| 3266 | public function supportsCreateDropDatabase() |
||
| 3270 | |||
| 3271 | /** |
||
| 3272 | * Whether the platform supports getting the affected rows of a recent update/delete type query. |
||
| 3273 | * |
||
| 3274 | * @return bool |
||
| 3275 | */ |
||
| 3276 | public function supportsGettingAffectedRows() |
||
| 3280 | |||
| 3281 | /** |
||
| 3282 | * Whether this platform support to add inline column comments as postfix. |
||
| 3283 | * |
||
| 3284 | * @return bool |
||
| 3285 | */ |
||
| 3286 | public function supportsInlineColumnComments() |
||
| 3290 | |||
| 3291 | /** |
||
| 3292 | * Whether this platform support the proprietary syntax "COMMENT ON asset". |
||
| 3293 | * |
||
| 3294 | * @return bool |
||
| 3295 | */ |
||
| 3296 | public function supportsCommentOnStatement() |
||
| 3300 | |||
| 3301 | /** |
||
| 3302 | * Does this platform have native guid type. |
||
| 3303 | * |
||
| 3304 | * @return bool |
||
| 3305 | */ |
||
| 3306 | public function hasNativeGuidType() |
||
| 3310 | |||
| 3311 | /** |
||
| 3312 | * Does this platform have native JSON type. |
||
| 3313 | * |
||
| 3314 | * @return bool |
||
| 3315 | */ |
||
| 3316 | public function hasNativeJsonType() |
||
| 3320 | |||
| 3321 | /** |
||
| 3322 | * @deprecated |
||
| 3323 | * @todo Remove in 3.0 |
||
| 3324 | */ |
||
| 3325 | public function getIdentityColumnNullInsertSQL() |
||
| 3329 | |||
| 3330 | /** |
||
| 3331 | * Whether this platform supports views. |
||
| 3332 | * |
||
| 3333 | * @return bool |
||
| 3334 | */ |
||
| 3335 | public function supportsViews() |
||
| 3339 | |||
| 3340 | /** |
||
| 3341 | * Does this platform support column collation? |
||
| 3342 | * |
||
| 3343 | * @return bool |
||
| 3344 | */ |
||
| 3345 | public function supportsColumnCollation() |
||
| 3349 | |||
| 3350 | /** |
||
| 3351 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3352 | * the format of a stored datetime value of this platform. |
||
| 3353 | * |
||
| 3354 | * @return string The format string. |
||
| 3355 | */ |
||
| 3356 | public function getDateTimeFormatString() |
||
| 3360 | |||
| 3361 | /** |
||
| 3362 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3363 | * the format of a stored datetime with timezone value of this platform. |
||
| 3364 | * |
||
| 3365 | * @return string The format string. |
||
| 3366 | */ |
||
| 3367 | public function getDateTimeTzFormatString() |
||
| 3371 | |||
| 3372 | /** |
||
| 3373 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3374 | * the format of a stored date value of this platform. |
||
| 3375 | * |
||
| 3376 | * @return string The format string. |
||
| 3377 | */ |
||
| 3378 | public function getDateFormatString() |
||
| 3382 | |||
| 3383 | /** |
||
| 3384 | * Gets the format string, as accepted by the date() function, that describes |
||
| 3385 | * the format of a stored time value of this platform. |
||
| 3386 | * |
||
| 3387 | * @return string The format string. |
||
| 3388 | */ |
||
| 3389 | public function getTimeFormatString() |
||
| 3393 | |||
| 3394 | /** |
||
| 3395 | * Adds an driver-specific LIMIT clause to the query. |
||
| 3396 | * |
||
| 3397 | * @param string $query |
||
| 3398 | * @param int|null $limit |
||
| 3399 | * @param int|null $offset |
||
| 3400 | * |
||
| 3401 | * @return string |
||
| 3402 | * |
||
| 3403 | * @throws DBALException |
||
| 3404 | */ |
||
| 3405 | final public function modifyLimitQuery($query, $limit, $offset = null) |
||
| 3429 | |||
| 3430 | /** |
||
| 3431 | * Adds an platform-specific LIMIT clause to the query. |
||
| 3432 | * |
||
| 3433 | * @param string $query |
||
| 3434 | * @param int|null $limit |
||
| 3435 | * @param int|null $offset |
||
| 3436 | * |
||
| 3437 | * @return string |
||
| 3438 | */ |
||
| 3439 | protected function doModifyLimitQuery($query, $limit, $offset) |
||
| 3451 | |||
| 3452 | /** |
||
| 3453 | * Whether the database platform support offsets in modify limit clauses. |
||
| 3454 | * |
||
| 3455 | * @return bool |
||
| 3456 | */ |
||
| 3457 | public function supportsLimitOffset() |
||
| 3461 | |||
| 3462 | /** |
||
| 3463 | * Gets the character casing of a column in an SQL result set of this platform. |
||
| 3464 | * |
||
| 3465 | * @param string $column The column name for which to get the correct character casing. |
||
| 3466 | * |
||
| 3467 | * @return string The column name in the character casing used in SQL result sets. |
||
| 3468 | */ |
||
| 3469 | public function getSQLResultCasing($column) |
||
| 3473 | |||
| 3474 | /** |
||
| 3475 | * Makes any fixes to a name of a schema element (table, sequence, ...) that are required |
||
| 3476 | * by restrictions of the platform, like a maximum length. |
||
| 3477 | * |
||
| 3478 | * @param string $schemaElementName |
||
| 3479 | * |
||
| 3480 | * @return string |
||
| 3481 | */ |
||
| 3482 | public function fixSchemaElementName($schemaElementName) |
||
| 3486 | |||
| 3487 | /** |
||
| 3488 | * Maximum length of any given database identifier, like tables or column names. |
||
| 3489 | * |
||
| 3490 | * @return int |
||
| 3491 | */ |
||
| 3492 | public function getMaxIdentifierLength() |
||
| 3496 | |||
| 3497 | /** |
||
| 3498 | * Returns the insert SQL for an empty insert statement. |
||
| 3499 | * |
||
| 3500 | * @param string $tableName |
||
| 3501 | * @param string $identifierColumnName |
||
| 3502 | * |
||
| 3503 | * @return string |
||
| 3504 | */ |
||
| 3505 | public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) |
||
| 3509 | |||
| 3510 | /** |
||
| 3511 | * Generates a Truncate Table SQL statement for a given table. |
||
| 3512 | * |
||
| 3513 | * Cascade is not supported on many platforms but would optionally cascade the truncate by |
||
| 3514 | * following the foreign keys. |
||
| 3515 | * |
||
| 3516 | * @param string $tableName |
||
| 3517 | * @param bool $cascade |
||
| 3518 | * |
||
| 3519 | * @return string |
||
| 3520 | */ |
||
| 3521 | public function getTruncateTableSQL($tableName, $cascade = false) |
||
| 3527 | |||
| 3528 | /** |
||
| 3529 | * This is for test reasons, many vendors have special requirements for dummy statements. |
||
| 3530 | * |
||
| 3531 | * @return string |
||
| 3532 | */ |
||
| 3533 | public function getDummySelectSQL() |
||
| 3539 | |||
| 3540 | /** |
||
| 3541 | * Returns the SQL to create a new savepoint. |
||
| 3542 | * |
||
| 3543 | * @param string $savepoint |
||
| 3544 | * |
||
| 3545 | * @return string |
||
| 3546 | */ |
||
| 3547 | public function createSavePoint($savepoint) |
||
| 3551 | |||
| 3552 | /** |
||
| 3553 | * Returns the SQL to release a savepoint. |
||
| 3554 | * |
||
| 3555 | * @param string $savepoint |
||
| 3556 | * |
||
| 3557 | * @return string |
||
| 3558 | */ |
||
| 3559 | public function releaseSavePoint($savepoint) |
||
| 3563 | |||
| 3564 | /** |
||
| 3565 | * Returns the SQL to rollback a savepoint. |
||
| 3566 | * |
||
| 3567 | * @param string $savepoint |
||
| 3568 | * |
||
| 3569 | * @return string |
||
| 3570 | */ |
||
| 3571 | public function rollbackSavePoint($savepoint) |
||
| 3575 | |||
| 3576 | /** |
||
| 3577 | * Returns the keyword list instance of this platform. |
||
| 3578 | * |
||
| 3579 | * @return \Doctrine\DBAL\Platforms\Keywords\KeywordList |
||
| 3580 | * |
||
| 3581 | * @throws \Doctrine\DBAL\DBALException If no keyword list is specified. |
||
| 3582 | */ |
||
| 3583 | final public function getReservedKeywordsList() |
||
| 3601 | |||
| 3602 | /** |
||
| 3603 | * Returns the class name of the reserved keywords list. |
||
| 3604 | * |
||
| 3605 | * @return string |
||
| 3606 | * |
||
| 3607 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
| 3608 | */ |
||
| 3609 | protected function getReservedKeywordsClass() |
||
| 3613 | |||
| 3614 | /** |
||
| 3615 | * Quotes a literal string. |
||
| 3616 | * This method is NOT meant to fix SQL injections! |
||
| 3617 | * It is only meant to escape this platform's string literal |
||
| 3618 | * quote character inside the given literal string. |
||
| 3619 | * |
||
| 3620 | * @param string $str The literal string to be quoted. |
||
| 3621 | * |
||
| 3622 | * @return string The quoted literal string. |
||
| 3623 | */ |
||
| 3624 | public function quoteStringLiteral($str) |
||
| 3630 | |||
| 3631 | /** |
||
| 3632 | * Gets the character used for string literal quoting. |
||
| 3633 | * |
||
| 3634 | * @return string |
||
| 3635 | */ |
||
| 3636 | public function getStringLiteralQuoteCharacter() |
||
| 3640 | |||
| 3641 | /** |
||
| 3642 | * Escapes metacharacters in a string intended to be used with a LIKE |
||
| 3643 | * operator. |
||
| 3644 | * |
||
| 3645 | * @param string $inputString a literal, unquoted string |
||
| 3646 | * @param string $escapeChar should be reused by the caller in the LIKE |
||
| 3647 | * expression. |
||
| 3648 | */ |
||
| 3649 | final public function escapeStringForLike(string $inputString, string $escapeChar) : string |
||
| 3657 | |||
| 3658 | protected function getLikeWildcardCharacters() : string |
||
| 3662 | } |
||
| 3663 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.