Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
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 |
||
60 | abstract class AbstractPlatform |
||
61 | { |
||
62 | /** |
||
63 | * @var integer |
||
64 | */ |
||
65 | const CREATE_INDEXES = 1; |
||
66 | |||
67 | /** |
||
68 | * @var integer |
||
69 | */ |
||
70 | const CREATE_FOREIGNKEYS = 2; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | const DATE_INTERVAL_UNIT_SECOND = 'SECOND'; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | const DATE_INTERVAL_UNIT_MINUTE = 'MINUTE'; |
||
81 | |||
82 | /** |
||
83 | * @var string |
||
84 | */ |
||
85 | const DATE_INTERVAL_UNIT_HOUR = 'HOUR'; |
||
86 | |||
87 | /** |
||
88 | * @var string |
||
89 | */ |
||
90 | const DATE_INTERVAL_UNIT_DAY = 'DAY'; |
||
91 | |||
92 | /** |
||
93 | * @var string |
||
94 | */ |
||
95 | const DATE_INTERVAL_UNIT_WEEK = 'WEEK'; |
||
96 | |||
97 | /** |
||
98 | * @var string |
||
99 | */ |
||
100 | const DATE_INTERVAL_UNIT_MONTH = 'MONTH'; |
||
101 | |||
102 | /** |
||
103 | * @var string |
||
104 | */ |
||
105 | const DATE_INTERVAL_UNIT_QUARTER = 'QUARTER'; |
||
106 | |||
107 | /** |
||
108 | * @var string |
||
109 | */ |
||
110 | const DATE_INTERVAL_UNIT_YEAR = 'YEAR'; |
||
111 | |||
112 | /** |
||
113 | * @var integer |
||
114 | */ |
||
115 | const TRIM_UNSPECIFIED = 0; |
||
116 | |||
117 | /** |
||
118 | * @var integer |
||
119 | */ |
||
120 | const TRIM_LEADING = 1; |
||
121 | |||
122 | /** |
||
123 | * @var integer |
||
124 | */ |
||
125 | const TRIM_TRAILING = 2; |
||
126 | |||
127 | /** |
||
128 | * @var integer |
||
129 | */ |
||
130 | const TRIM_BOTH = 3; |
||
131 | |||
132 | /** |
||
133 | * @var array|null |
||
134 | */ |
||
135 | protected $doctrineTypeMapping = null; |
||
136 | |||
137 | /** |
||
138 | * Contains a list of all columns that should generate parseable column comments for type-detection |
||
139 | * in reverse engineering scenarios. |
||
140 | * |
||
141 | * @var array|null |
||
142 | */ |
||
143 | protected $doctrineTypeComments = null; |
||
144 | |||
145 | /** |
||
146 | * @var \Doctrine\Common\EventManager |
||
147 | */ |
||
148 | protected $_eventManager; |
||
149 | |||
150 | /** |
||
151 | * Holds the KeywordList instance for the current platform. |
||
152 | * |
||
153 | * @var \Doctrine\DBAL\Platforms\Keywords\KeywordList |
||
154 | */ |
||
155 | protected $_keywords; |
||
156 | |||
157 | /** |
||
158 | * Constructor. |
||
159 | */ |
||
160 | 3017 | public function __construct() |
|
163 | |||
164 | /** |
||
165 | * Sets the EventManager used by the Platform. |
||
166 | * |
||
167 | * @param \Doctrine\Common\EventManager $eventManager |
||
168 | */ |
||
169 | 76 | public function setEventManager(EventManager $eventManager) |
|
173 | |||
174 | /** |
||
175 | * Gets the EventManager used by the Platform. |
||
176 | * |
||
177 | * @return \Doctrine\Common\EventManager |
||
178 | */ |
||
179 | 43 | public function getEventManager() |
|
183 | |||
184 | /** |
||
185 | * Returns the SQL snippet that declares a boolean column. |
||
186 | * |
||
187 | * @param array $columnDef |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | abstract public function getBooleanTypeDeclarationSQL(array $columnDef); |
||
192 | |||
193 | /** |
||
194 | * Returns the SQL snippet that declares a 4 byte integer column. |
||
195 | * |
||
196 | * @param array $columnDef |
||
197 | * |
||
198 | * @return string |
||
199 | */ |
||
200 | abstract public function getIntegerTypeDeclarationSQL(array $columnDef); |
||
201 | |||
202 | /** |
||
203 | * Returns the SQL snippet that declares an 8 byte integer column. |
||
204 | * |
||
205 | * @param array $columnDef |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | abstract public function getBigIntTypeDeclarationSQL(array $columnDef); |
||
210 | |||
211 | /** |
||
212 | * Returns the SQL snippet that declares a 2 byte integer column. |
||
213 | * |
||
214 | * @param array $columnDef |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | abstract public function getSmallIntTypeDeclarationSQL(array $columnDef); |
||
219 | |||
220 | /** |
||
221 | * Returns the SQL snippet that declares common properties of an integer column. |
||
222 | * |
||
223 | * @param array $columnDef |
||
224 | * |
||
225 | * @return string |
||
226 | */ |
||
227 | abstract protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef); |
||
228 | |||
229 | /** |
||
230 | * Lazy load Doctrine Type Mappings. |
||
231 | * |
||
232 | * @return void |
||
233 | */ |
||
234 | abstract protected function initializeDoctrineTypeMappings(); |
||
235 | |||
236 | /** |
||
237 | * Initializes Doctrine Type Mappings with the platform defaults |
||
238 | * and with all additional type mappings. |
||
239 | * |
||
240 | * @return void |
||
241 | */ |
||
242 | 87 | private function initializeAllDoctrineTypeMappings() |
|
252 | |||
253 | /** |
||
254 | * Returns the SQL snippet used to declare a VARCHAR column type. |
||
255 | * |
||
256 | * @param array $field |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | 304 | public function getVarcharTypeDeclarationSQL(array $field) |
|
274 | |||
275 | /** |
||
276 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
277 | * |
||
278 | * @param array $field The column definition. |
||
279 | * |
||
280 | * @return string |
||
281 | */ |
||
282 | 20 | public function getBinaryTypeDeclarationSQL(array $field) |
|
296 | |||
297 | /** |
||
298 | * Returns the SQL snippet to declare a GUID/UUID field. |
||
299 | * |
||
300 | * By default this maps directly to a CHAR(36) and only maps to more |
||
301 | * special datatypes when the underlying databases support this datatype. |
||
302 | * |
||
303 | * @param array $field |
||
304 | * |
||
305 | * @return string |
||
306 | */ |
||
307 | 5 | public function getGuidTypeDeclarationSQL(array $field) |
|
314 | |||
315 | /** |
||
316 | * Returns the SQL snippet to declare a JSON field. |
||
317 | * |
||
318 | * By default this maps directly to a CLOB and only maps to more |
||
319 | * special datatypes when the underlying databases support this datatype. |
||
320 | * |
||
321 | * @param array $field |
||
322 | * |
||
323 | * @return string |
||
324 | */ |
||
325 | 28 | public function getJsonTypeDeclarationSQL(array $field) |
|
329 | |||
330 | /** |
||
331 | * @param integer $length |
||
332 | * @param boolean $fixed |
||
333 | * |
||
334 | * @return string |
||
335 | * |
||
336 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
337 | */ |
||
338 | protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) |
||
342 | |||
343 | /** |
||
344 | * Returns the SQL snippet used to declare a BINARY/VARBINARY column type. |
||
345 | * |
||
346 | * @param integer $length The length of the column. |
||
347 | * @param boolean $fixed Whether the column length is fixed. |
||
348 | * |
||
349 | * @return string |
||
350 | * |
||
351 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
352 | */ |
||
353 | protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) |
||
357 | |||
358 | /** |
||
359 | * Returns the SQL snippet used to declare a CLOB column type. |
||
360 | * |
||
361 | * @param array $field |
||
362 | * |
||
363 | * @return string |
||
364 | */ |
||
365 | abstract public function getClobTypeDeclarationSQL(array $field); |
||
366 | |||
367 | /** |
||
368 | * Returns the SQL Snippet used to declare a BLOB column type. |
||
369 | * |
||
370 | * @param array $field |
||
371 | * |
||
372 | * @return string |
||
373 | */ |
||
374 | abstract public function getBlobTypeDeclarationSQL(array $field); |
||
375 | |||
376 | /** |
||
377 | * Gets the name of the platform. |
||
378 | * |
||
379 | * @return string |
||
380 | */ |
||
381 | abstract public function getName(); |
||
382 | |||
383 | /** |
||
384 | * Registers a doctrine type to be used in conjunction with a column type of this platform. |
||
385 | * |
||
386 | * @param string $dbType |
||
387 | * @param string $doctrineType |
||
388 | * |
||
389 | * @throws \Doctrine\DBAL\DBALException If the type is not found. |
||
390 | */ |
||
391 | 49 | public function registerDoctrineTypeMapping($dbType, $doctrineType) |
|
410 | |||
411 | /** |
||
412 | * Gets the Doctrine type that is mapped for the given database column type. |
||
413 | * |
||
414 | * @param string $dbType |
||
415 | * |
||
416 | * @return string |
||
417 | * |
||
418 | * @throws \Doctrine\DBAL\DBALException |
||
419 | */ |
||
420 | 91 | public function getDoctrineTypeMapping($dbType) |
|
434 | |||
435 | /** |
||
436 | * Checks if a database type is currently supported by this platform. |
||
437 | * |
||
438 | * @param string $dbType |
||
439 | * |
||
440 | * @return boolean |
||
441 | */ |
||
442 | 20 | public function hasDoctrineTypeMappingFor($dbType) |
|
452 | |||
453 | /** |
||
454 | * Initializes the Doctrine Type comments instance variable for in_array() checks. |
||
455 | * |
||
456 | * @return void |
||
457 | */ |
||
458 | 748 | protected function initializeCommentedDoctrineTypes() |
|
470 | |||
471 | /** |
||
472 | * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type? |
||
473 | * |
||
474 | * @param \Doctrine\DBAL\Types\Type $doctrineType |
||
475 | * |
||
476 | * @return boolean |
||
477 | */ |
||
478 | 860 | public function isCommentedDoctrineType(Type $doctrineType) |
|
486 | |||
487 | /** |
||
488 | * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements. |
||
489 | * |
||
490 | * @param string|\Doctrine\DBAL\Types\Type $doctrineType |
||
491 | * |
||
492 | * @return void |
||
493 | */ |
||
494 | 16 | public function markDoctrineTypeCommented($doctrineType) |
|
502 | |||
503 | /** |
||
504 | * Gets the comment to append to a column comment that helps parsing this type in reverse engineering. |
||
505 | * |
||
506 | * @param \Doctrine\DBAL\Types\Type $doctrineType |
||
507 | * |
||
508 | * @return string |
||
509 | */ |
||
510 | 38 | public function getDoctrineTypeComment(Type $doctrineType) |
|
514 | |||
515 | /** |
||
516 | * Gets the comment of a passed column modified by potential doctrine type comment hints. |
||
517 | * |
||
518 | * @param \Doctrine\DBAL\Schema\Column $column |
||
519 | * |
||
520 | * @return string |
||
521 | */ |
||
522 | 445 | protected function getColumnComment(Column $column) |
|
532 | |||
533 | /** |
||
534 | * Gets the character used for identifier quoting. |
||
535 | * |
||
536 | * @return string |
||
537 | */ |
||
538 | 274 | public function getIdentifierQuoteCharacter() |
|
542 | |||
543 | /** |
||
544 | * Gets the string portion that starts an SQL comment. |
||
545 | * |
||
546 | * @return string |
||
547 | */ |
||
548 | public function getSqlCommentStartString() |
||
552 | |||
553 | /** |
||
554 | * Gets the string portion that ends an SQL comment. |
||
555 | * |
||
556 | * @return string |
||
557 | */ |
||
558 | public function getSqlCommentEndString() |
||
562 | |||
563 | /** |
||
564 | * Gets the maximum length of a varchar field. |
||
565 | * |
||
566 | * @return integer |
||
567 | */ |
||
568 | 178 | public function getVarcharMaxLength() |
|
572 | |||
573 | /** |
||
574 | * Gets the default length of a varchar field. |
||
575 | * |
||
576 | * @return integer |
||
577 | */ |
||
578 | 61 | public function getVarcharDefaultLength() |
|
582 | |||
583 | /** |
||
584 | * Gets the maximum length of a binary field. |
||
585 | * |
||
586 | * @return integer |
||
587 | */ |
||
588 | public function getBinaryMaxLength() |
||
592 | |||
593 | /** |
||
594 | * Gets the default length of a binary field. |
||
595 | * |
||
596 | * @return integer |
||
597 | */ |
||
598 | 12 | public function getBinaryDefaultLength() |
|
602 | |||
603 | /** |
||
604 | * Gets all SQL wildcard characters of the platform. |
||
605 | * |
||
606 | * @return array |
||
607 | */ |
||
608 | public function getWildcards() |
||
612 | |||
613 | /** |
||
614 | * Returns the regular expression operator. |
||
615 | * |
||
616 | * @return string |
||
617 | * |
||
618 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
619 | */ |
||
620 | 5 | public function getRegexpExpression() |
|
624 | |||
625 | /** |
||
626 | * Returns the global unique identifier expression. |
||
627 | * |
||
628 | * @return string |
||
629 | * |
||
630 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
631 | */ |
||
632 | public function getGuidExpression() |
||
636 | |||
637 | /** |
||
638 | * Returns the SQL snippet to get the average value of a column. |
||
639 | * |
||
640 | * @param string $column The column to use. |
||
641 | * |
||
642 | * @return string Generated SQL including an AVG aggregate function. |
||
643 | */ |
||
644 | public function getAvgExpression($column) |
||
648 | |||
649 | /** |
||
650 | * Returns the SQL snippet to get the number of rows (without a NULL value) of a column. |
||
651 | * |
||
652 | * If a '*' is used instead of a column the number of selected rows is returned. |
||
653 | * |
||
654 | * @param string|integer $column The column to use. |
||
655 | * |
||
656 | * @return string Generated SQL including a COUNT aggregate function. |
||
657 | */ |
||
658 | public function getCountExpression($column) |
||
662 | |||
663 | /** |
||
664 | * Returns the SQL snippet to get the highest value of a column. |
||
665 | * |
||
666 | * @param string $column The column to use. |
||
667 | * |
||
668 | * @return string Generated SQL including a MAX aggregate function. |
||
669 | */ |
||
670 | public function getMaxExpression($column) |
||
674 | |||
675 | /** |
||
676 | * Returns the SQL snippet to get the lowest value of a column. |
||
677 | * |
||
678 | * @param string $column The column to use. |
||
679 | * |
||
680 | * @return string Generated SQL including a MIN aggregate function. |
||
681 | */ |
||
682 | public function getMinExpression($column) |
||
686 | |||
687 | /** |
||
688 | * Returns the SQL snippet to get the total sum of a column. |
||
689 | * |
||
690 | * @param string $column The column to use. |
||
691 | * |
||
692 | * @return string Generated SQL including a SUM aggregate function. |
||
693 | */ |
||
694 | public function getSumExpression($column) |
||
698 | |||
699 | // scalar functions |
||
700 | |||
701 | /** |
||
702 | * Returns the SQL snippet to get the md5 sum of a field. |
||
703 | * |
||
704 | * Note: Not SQL92, but common functionality. |
||
705 | * |
||
706 | * @param string $column |
||
707 | * |
||
708 | * @return string |
||
709 | */ |
||
710 | public function getMd5Expression($column) |
||
714 | |||
715 | /** |
||
716 | * Returns the SQL snippet to get the length of a text field. |
||
717 | * |
||
718 | * @param string $column |
||
719 | * |
||
720 | * @return string |
||
721 | */ |
||
722 | public function getLengthExpression($column) |
||
726 | |||
727 | /** |
||
728 | * Returns the SQL snippet to get the squared value of a column. |
||
729 | * |
||
730 | * @param string $column The column to use. |
||
731 | * |
||
732 | * @return string Generated SQL including an SQRT aggregate function. |
||
733 | */ |
||
734 | public function getSqrtExpression($column) |
||
738 | |||
739 | /** |
||
740 | * Returns the SQL snippet to round a numeric field to the number of decimals specified. |
||
741 | * |
||
742 | * @param string $column |
||
743 | * @param integer $decimals |
||
744 | * |
||
745 | * @return string |
||
746 | */ |
||
747 | public function getRoundExpression($column, $decimals = 0) |
||
751 | |||
752 | /** |
||
753 | * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2. |
||
754 | * |
||
755 | * @param string $expression1 |
||
756 | * @param string $expression2 |
||
757 | * |
||
758 | * @return string |
||
759 | */ |
||
760 | public function getModExpression($expression1, $expression2) |
||
764 | |||
765 | /** |
||
766 | * Returns the SQL snippet to trim a string. |
||
767 | * |
||
768 | * @param string $str The expression to apply the trim to. |
||
769 | * @param integer $pos The position of the trim (leading/trailing/both). |
||
770 | * @param string|boolean $char The char to trim, has to be quoted already. Defaults to space. |
||
771 | * |
||
772 | * @return string |
||
773 | */ |
||
774 | public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = false) |
||
802 | |||
803 | /** |
||
804 | * Returns the SQL snippet to trim trailing space characters from the expression. |
||
805 | * |
||
806 | * @param string $str Literal string or column name. |
||
807 | * |
||
808 | * @return string |
||
809 | */ |
||
810 | 4 | public function getRtrimExpression($str) |
|
814 | |||
815 | /** |
||
816 | * Returns the SQL snippet to trim leading space characters from the expression. |
||
817 | * |
||
818 | * @param string $str Literal string or column name. |
||
819 | * |
||
820 | * @return string |
||
821 | */ |
||
822 | 4 | public function getLtrimExpression($str) |
|
826 | |||
827 | /** |
||
828 | * Returns the SQL snippet to change all characters from the expression to uppercase, |
||
829 | * according to the current character set mapping. |
||
830 | * |
||
831 | * @param string $str Literal string or column name. |
||
832 | * |
||
833 | * @return string |
||
834 | */ |
||
835 | public function getUpperExpression($str) |
||
839 | |||
840 | /** |
||
841 | * Returns the SQL snippet to change all characters from the expression to lowercase, |
||
842 | * according to the current character set mapping. |
||
843 | * |
||
844 | * @param string $str Literal string or column name. |
||
845 | * |
||
846 | * @return string |
||
847 | */ |
||
848 | public function getLowerExpression($str) |
||
852 | |||
853 | /** |
||
854 | * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str. |
||
855 | * |
||
856 | * @param string $str Literal string. |
||
857 | * @param string $substr Literal string to find. |
||
858 | * @param integer|boolean $startPos Position to start at, beginning of string by default. |
||
859 | * |
||
860 | * @return string |
||
861 | * |
||
862 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
863 | */ |
||
864 | public function getLocateExpression($str, $substr, $startPos = false) |
||
868 | |||
869 | /** |
||
870 | * Returns the SQL snippet to get the current system date. |
||
871 | * |
||
872 | * @return string |
||
873 | */ |
||
874 | public function getNowExpression() |
||
878 | |||
879 | /** |
||
880 | * Returns a SQL snippet to get a substring inside an SQL statement. |
||
881 | * |
||
882 | * Note: Not SQL92, but common functionality. |
||
883 | * |
||
884 | * SQLite only supports the 2 parameter variant of this function. |
||
885 | * |
||
886 | * @param string $value An sql string literal or column name/alias. |
||
887 | * @param integer $from Where to start the substring portion. |
||
888 | * @param integer|null $length The substring portion length. |
||
889 | * |
||
890 | * @return string |
||
891 | */ |
||
892 | View Code Duplication | public function getSubstringExpression($value, $from, $length = null) |
|
900 | |||
901 | /** |
||
902 | * Returns a SQL snippet to concatenate the given expressions. |
||
903 | * |
||
904 | * Accepts an arbitrary number of string parameters. Each parameter must contain an expression. |
||
905 | * |
||
906 | * @return string |
||
907 | */ |
||
908 | 5 | public function getConcatExpression() |
|
912 | |||
913 | /** |
||
914 | * Returns the SQL for a logical not. |
||
915 | * |
||
916 | * Example: |
||
917 | * <code> |
||
918 | * $q = new Doctrine_Query(); |
||
919 | * $e = $q->expr; |
||
920 | * $q->select('*')->from('table') |
||
921 | * ->where($e->eq('id', $e->not('null')); |
||
922 | * </code> |
||
923 | * |
||
924 | * @param string $expression |
||
925 | * |
||
926 | * @return string The logical expression. |
||
927 | */ |
||
928 | public function getNotExpression($expression) |
||
932 | |||
933 | /** |
||
934 | * Returns the SQL that checks if an expression is null. |
||
935 | * |
||
936 | * @param string $expression The expression that should be compared to null. |
||
937 | * |
||
938 | * @return string The logical expression. |
||
939 | */ |
||
940 | 4 | public function getIsNullExpression($expression) |
|
944 | |||
945 | /** |
||
946 | * Returns the SQL that checks if an expression is not null. |
||
947 | * |
||
948 | * @param string $expression The expression that should be compared to null. |
||
949 | * |
||
950 | * @return string The logical expression. |
||
951 | */ |
||
952 | public function getIsNotNullExpression($expression) |
||
956 | |||
957 | /** |
||
958 | * Returns the SQL that checks if an expression evaluates to a value between two values. |
||
959 | * |
||
960 | * The parameter $expression is checked if it is between $value1 and $value2. |
||
961 | * |
||
962 | * Note: There is a slight difference in the way BETWEEN works on some databases. |
||
963 | * http://www.w3schools.com/sql/sql_between.asp. If you want complete database |
||
964 | * independence you should avoid using between(). |
||
965 | * |
||
966 | * @param string $expression The value to compare to. |
||
967 | * @param string $value1 The lower value to compare with. |
||
968 | * @param string $value2 The higher value to compare with. |
||
969 | * |
||
970 | * @return string The logical expression. |
||
971 | */ |
||
972 | public function getBetweenExpression($expression, $value1, $value2) |
||
976 | |||
977 | /** |
||
978 | * Returns the SQL to get the arccosine of a value. |
||
979 | * |
||
980 | * @param string $value |
||
981 | * |
||
982 | * @return string |
||
983 | */ |
||
984 | public function getAcosExpression($value) |
||
988 | |||
989 | /** |
||
990 | * Returns the SQL to get the sine of a value. |
||
991 | * |
||
992 | * @param string $value |
||
993 | * |
||
994 | * @return string |
||
995 | */ |
||
996 | public function getSinExpression($value) |
||
1000 | |||
1001 | /** |
||
1002 | * Returns the SQL to get the PI value. |
||
1003 | * |
||
1004 | * @return string |
||
1005 | */ |
||
1006 | public function getPiExpression() |
||
1010 | |||
1011 | /** |
||
1012 | * Returns the SQL to get the cosine of a value. |
||
1013 | * |
||
1014 | * @param string $value |
||
1015 | * |
||
1016 | * @return string |
||
1017 | */ |
||
1018 | public function getCosExpression($value) |
||
1022 | |||
1023 | /** |
||
1024 | * Returns the SQL to calculate the difference in days between the two passed dates. |
||
1025 | * |
||
1026 | * Computes diff = date1 - date2. |
||
1027 | * |
||
1028 | * @param string $date1 |
||
1029 | * @param string $date2 |
||
1030 | * |
||
1031 | * @return string |
||
1032 | * |
||
1033 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1034 | */ |
||
1035 | public function getDateDiffExpression($date1, $date2) |
||
1039 | |||
1040 | /** |
||
1041 | * Returns the SQL to add the number of given seconds to a date. |
||
1042 | * |
||
1043 | * @param string $date |
||
1044 | * @param integer $seconds |
||
1045 | * |
||
1046 | * @return string |
||
1047 | * |
||
1048 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1049 | */ |
||
1050 | 6 | public function getDateAddSecondsExpression($date, $seconds) |
|
1054 | |||
1055 | /** |
||
1056 | * Returns the SQL to subtract the number of given seconds from a date. |
||
1057 | * |
||
1058 | * @param string $date |
||
1059 | * @param integer $seconds |
||
1060 | * |
||
1061 | * @return string |
||
1062 | * |
||
1063 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1064 | */ |
||
1065 | 6 | public function getDateSubSecondsExpression($date, $seconds) |
|
1069 | |||
1070 | /** |
||
1071 | * Returns the SQL to add the number of given minutes to a date. |
||
1072 | * |
||
1073 | * @param string $date |
||
1074 | * @param integer $minutes |
||
1075 | * |
||
1076 | * @return string |
||
1077 | * |
||
1078 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1079 | */ |
||
1080 | 6 | public function getDateAddMinutesExpression($date, $minutes) |
|
1084 | |||
1085 | /** |
||
1086 | * Returns the SQL to subtract the number of given minutes from a date. |
||
1087 | * |
||
1088 | * @param string $date |
||
1089 | * @param integer $minutes |
||
1090 | * |
||
1091 | * @return string |
||
1092 | * |
||
1093 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1094 | */ |
||
1095 | 6 | public function getDateSubMinutesExpression($date, $minutes) |
|
1099 | |||
1100 | /** |
||
1101 | * Returns the SQL to add the number of given hours to a date. |
||
1102 | * |
||
1103 | * @param string $date |
||
1104 | * @param integer $hours |
||
1105 | * |
||
1106 | * @return string |
||
1107 | * |
||
1108 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1109 | */ |
||
1110 | 6 | public function getDateAddHourExpression($date, $hours) |
|
1114 | |||
1115 | /** |
||
1116 | * Returns the SQL to subtract the number of given hours to a date. |
||
1117 | * |
||
1118 | * @param string $date |
||
1119 | * @param integer $hours |
||
1120 | * |
||
1121 | * @return string |
||
1122 | * |
||
1123 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1124 | */ |
||
1125 | 6 | public function getDateSubHourExpression($date, $hours) |
|
1129 | |||
1130 | /** |
||
1131 | * Returns the SQL to add the number of given days to a date. |
||
1132 | * |
||
1133 | * @param string $date |
||
1134 | * @param integer $days |
||
1135 | * |
||
1136 | * @return string |
||
1137 | * |
||
1138 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1139 | */ |
||
1140 | 6 | public function getDateAddDaysExpression($date, $days) |
|
1144 | |||
1145 | /** |
||
1146 | * Returns the SQL to subtract the number of given days to a date. |
||
1147 | * |
||
1148 | * @param string $date |
||
1149 | * @param integer $days |
||
1150 | * |
||
1151 | * @return string |
||
1152 | * |
||
1153 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1154 | */ |
||
1155 | 6 | public function getDateSubDaysExpression($date, $days) |
|
1159 | |||
1160 | /** |
||
1161 | * Returns the SQL to add the number of given weeks to a date. |
||
1162 | * |
||
1163 | * @param string $date |
||
1164 | * @param integer $weeks |
||
1165 | * |
||
1166 | * @return string |
||
1167 | * |
||
1168 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1169 | */ |
||
1170 | 6 | public function getDateAddWeeksExpression($date, $weeks) |
|
1174 | |||
1175 | /** |
||
1176 | * Returns the SQL to subtract the number of given weeks from a date. |
||
1177 | * |
||
1178 | * @param string $date |
||
1179 | * @param integer $weeks |
||
1180 | * |
||
1181 | * @return string |
||
1182 | * |
||
1183 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1184 | */ |
||
1185 | 6 | public function getDateSubWeeksExpression($date, $weeks) |
|
1189 | |||
1190 | /** |
||
1191 | * Returns the SQL to add the number of given months to a date. |
||
1192 | * |
||
1193 | * @param string $date |
||
1194 | * @param integer $months |
||
1195 | * |
||
1196 | * @return string |
||
1197 | * |
||
1198 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1199 | */ |
||
1200 | 6 | public function getDateAddMonthExpression($date, $months) |
|
1204 | |||
1205 | /** |
||
1206 | * Returns the SQL to subtract the number of given months to a date. |
||
1207 | * |
||
1208 | * @param string $date |
||
1209 | * @param integer $months |
||
1210 | * |
||
1211 | * @return string |
||
1212 | * |
||
1213 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1214 | */ |
||
1215 | 6 | public function getDateSubMonthExpression($date, $months) |
|
1219 | |||
1220 | /** |
||
1221 | * Returns the SQL to add the number of given quarters to a date. |
||
1222 | * |
||
1223 | * @param string $date |
||
1224 | * @param integer $quarters |
||
1225 | * |
||
1226 | * @return string |
||
1227 | * |
||
1228 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1229 | */ |
||
1230 | 6 | public function getDateAddQuartersExpression($date, $quarters) |
|
1234 | |||
1235 | /** |
||
1236 | * Returns the SQL to subtract the number of given quarters from a date. |
||
1237 | * |
||
1238 | * @param string $date |
||
1239 | * @param integer $quarters |
||
1240 | * |
||
1241 | * @return string |
||
1242 | * |
||
1243 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1244 | */ |
||
1245 | 6 | public function getDateSubQuartersExpression($date, $quarters) |
|
1249 | |||
1250 | /** |
||
1251 | * Returns the SQL to add the number of given years to a date. |
||
1252 | * |
||
1253 | * @param string $date |
||
1254 | * @param integer $years |
||
1255 | * |
||
1256 | * @return string |
||
1257 | * |
||
1258 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1259 | */ |
||
1260 | 6 | public function getDateAddYearsExpression($date, $years) |
|
1264 | |||
1265 | /** |
||
1266 | * Returns the SQL to subtract the number of given years from a date. |
||
1267 | * |
||
1268 | * @param string $date |
||
1269 | * @param integer $years |
||
1270 | * |
||
1271 | * @return string |
||
1272 | * |
||
1273 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1274 | */ |
||
1275 | 6 | public function getDateSubYearsExpression($date, $years) |
|
1279 | |||
1280 | /** |
||
1281 | * Returns the SQL for a date arithmetic expression. |
||
1282 | * |
||
1283 | * @param string $date The column or literal representing a date to perform the arithmetic operation on. |
||
1284 | * @param string $operator The arithmetic operator (+ or -). |
||
1285 | * @param integer $interval The interval that shall be calculated into the date. |
||
1286 | * @param string $unit The unit of the interval that shall be calculated into the date. |
||
1287 | * One of the DATE_INTERVAL_UNIT_* constants. |
||
1288 | * |
||
1289 | * @return string |
||
1290 | * |
||
1291 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1292 | */ |
||
1293 | protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) |
||
1297 | |||
1298 | /** |
||
1299 | * Returns the SQL bit AND comparison expression. |
||
1300 | * |
||
1301 | * @param string $value1 |
||
1302 | * @param string $value2 |
||
1303 | * |
||
1304 | * @return string |
||
1305 | */ |
||
1306 | 15 | public function getBitAndComparisonExpression($value1, $value2) |
|
1310 | |||
1311 | /** |
||
1312 | * Returns the SQL bit OR comparison expression. |
||
1313 | * |
||
1314 | * @param string $value1 |
||
1315 | * @param string $value2 |
||
1316 | * |
||
1317 | * @return string |
||
1318 | */ |
||
1319 | 15 | public function getBitOrComparisonExpression($value1, $value2) |
|
1323 | |||
1324 | /** |
||
1325 | * Returns the FOR UPDATE expression. |
||
1326 | * |
||
1327 | * @return string |
||
1328 | */ |
||
1329 | public function getForUpdateSQL() |
||
1333 | |||
1334 | /** |
||
1335 | * Honors that some SQL vendors such as MsSql use table hints for locking instead of the ANSI SQL FOR UPDATE specification. |
||
1336 | * |
||
1337 | * @param string $fromClause The FROM clause to append the hint for the given lock mode to. |
||
1338 | * @param integer|null $lockMode One of the Doctrine\DBAL\LockMode::* constants. If null is given, nothing will |
||
1339 | * be appended to the FROM clause. |
||
1340 | * |
||
1341 | * @return string |
||
1342 | */ |
||
1343 | public function appendLockHint($fromClause, $lockMode) |
||
1347 | |||
1348 | /** |
||
1349 | * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock. |
||
1350 | * |
||
1351 | * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database |
||
1352 | * vendors allow to lighten this constraint up to be a real read lock. |
||
1353 | * |
||
1354 | * @return string |
||
1355 | */ |
||
1356 | public function getReadLockSQL() |
||
1360 | |||
1361 | /** |
||
1362 | * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows. |
||
1363 | * |
||
1364 | * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard. |
||
1365 | * |
||
1366 | * @return string |
||
1367 | */ |
||
1368 | public function getWriteLockSQL() |
||
1372 | |||
1373 | /** |
||
1374 | * Returns the SQL snippet to drop an existing database. |
||
1375 | * |
||
1376 | * @param string $database The name of the database that should be dropped. |
||
1377 | * |
||
1378 | * @return string |
||
1379 | */ |
||
1380 | 4 | public function getDropDatabaseSQL($database) |
|
1384 | |||
1385 | /** |
||
1386 | * Returns the SQL snippet to drop an existing table. |
||
1387 | * |
||
1388 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1389 | * |
||
1390 | * @return string |
||
1391 | * |
||
1392 | * @throws \InvalidArgumentException |
||
1393 | */ |
||
1394 | 102 | public function getDropTableSQL($table) |
|
1415 | |||
1416 | /** |
||
1417 | * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction. |
||
1418 | * |
||
1419 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1420 | * |
||
1421 | * @return string |
||
1422 | */ |
||
1423 | 2 | public function getDropTemporaryTableSQL($table) |
|
1427 | |||
1428 | /** |
||
1429 | * Returns the SQL to drop an index from a table. |
||
1430 | * |
||
1431 | * @param \Doctrine\DBAL\Schema\Index|string $index |
||
1432 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1433 | * |
||
1434 | * @return string |
||
1435 | * |
||
1436 | * @throws \InvalidArgumentException |
||
1437 | */ |
||
1438 | 9 | View Code Duplication | public function getDropIndexSQL($index, $table = null) |
1448 | |||
1449 | /** |
||
1450 | * Returns the SQL to drop a constraint. |
||
1451 | * |
||
1452 | * @param \Doctrine\DBAL\Schema\Constraint|string $constraint |
||
1453 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1454 | * |
||
1455 | * @return string |
||
1456 | */ |
||
1457 | 31 | View Code Duplication | public function getDropConstraintSQL($constraint, $table) |
1472 | |||
1473 | /** |
||
1474 | * Returns the SQL to drop a foreign key. |
||
1475 | * |
||
1476 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint|string $foreignKey |
||
1477 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1478 | * |
||
1479 | * @return string |
||
1480 | */ |
||
1481 | 17 | View Code Duplication | public function getDropForeignKeySQL($foreignKey, $table) |
1496 | |||
1497 | /** |
||
1498 | * Returns the SQL statement(s) to create a table with the specified name, columns and constraints |
||
1499 | * on this platform. |
||
1500 | * |
||
1501 | * @param \Doctrine\DBAL\Schema\Table $table |
||
1502 | * @param integer $createFlags |
||
1503 | * |
||
1504 | * @return array The sequence of SQL statements. |
||
1505 | * |
||
1506 | * @throws \Doctrine\DBAL\DBALException |
||
1507 | * @throws \InvalidArgumentException |
||
1508 | */ |
||
1509 | 350 | public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) |
|
1599 | |||
1600 | /** |
||
1601 | * @param string $tableName |
||
1602 | * @param string $columnName |
||
1603 | * @param string $comment |
||
1604 | * |
||
1605 | * @return string |
||
1606 | */ |
||
1607 | 31 | View Code Duplication | public function getCommentOnColumnSQL($tableName, $columnName, $comment) |
1616 | |||
1617 | /** |
||
1618 | * Returns the SQL to create inline comment on a column. |
||
1619 | * |
||
1620 | * @param string $comment |
||
1621 | * |
||
1622 | * @return string |
||
1623 | * |
||
1624 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1625 | */ |
||
1626 | 31 | public function getInlineColumnCommentSQL($comment) |
|
1634 | |||
1635 | /** |
||
1636 | * Returns the SQL used to create a table. |
||
1637 | * |
||
1638 | * @param string $tableName |
||
1639 | * @param array $columns |
||
1640 | * @param array $options |
||
1641 | * |
||
1642 | * @return array |
||
1643 | */ |
||
1644 | 23 | protected function _getCreateTableSQL($tableName, array $columns, array $options = []) |
|
1682 | |||
1683 | /** |
||
1684 | * @return string |
||
1685 | */ |
||
1686 | 2 | public function getCreateTemporaryTableSnippetSQL() |
|
1690 | |||
1691 | /** |
||
1692 | * Returns the SQL to create a sequence on this platform. |
||
1693 | * |
||
1694 | * @param \Doctrine\DBAL\Schema\Sequence $sequence |
||
1695 | * |
||
1696 | * @return string |
||
1697 | * |
||
1698 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1699 | */ |
||
1700 | public function getCreateSequenceSQL(Sequence $sequence) |
||
1704 | |||
1705 | /** |
||
1706 | * Returns the SQL to change a sequence on this platform. |
||
1707 | * |
||
1708 | * @param \Doctrine\DBAL\Schema\Sequence $sequence |
||
1709 | * |
||
1710 | * @return string |
||
1711 | * |
||
1712 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1713 | */ |
||
1714 | public function getAlterSequenceSQL(Sequence $sequence) |
||
1718 | |||
1719 | /** |
||
1720 | * Returns the SQL to create a constraint on a table on this platform. |
||
1721 | * |
||
1722 | * @param \Doctrine\DBAL\Schema\Constraint $constraint |
||
1723 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1724 | * |
||
1725 | * @return string |
||
1726 | * |
||
1727 | * @throws \InvalidArgumentException |
||
1728 | */ |
||
1729 | 14 | public function getCreateConstraintSQL(Constraint $constraint, $table) |
|
1730 | { |
||
1731 | 14 | if ($table instanceof Table) { |
|
1732 | $table = $table->getQuotedName($this); |
||
1733 | } |
||
1734 | |||
1735 | 14 | $query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $constraint->getQuotedName($this); |
|
1736 | |||
1737 | 14 | $columnList = '('. implode(', ', $constraint->getQuotedColumns($this)) . ')'; |
|
1738 | |||
1739 | 14 | $referencesClause = ''; |
|
1740 | 14 | if ($constraint instanceof Index) { |
|
1741 | 14 | if ($constraint->isPrimary()) { |
|
1742 | 14 | $query .= ' PRIMARY KEY'; |
|
1743 | 11 | } elseif ($constraint->isUnique()) { |
|
1744 | 11 | $query .= ' UNIQUE'; |
|
1745 | } else { |
||
1746 | throw new \InvalidArgumentException( |
||
1747 | 14 | 'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().' |
|
1748 | ); |
||
1749 | } |
||
1750 | 11 | } elseif ($constraint instanceof ForeignKeyConstraint) { |
|
1751 | 11 | $query .= ' FOREIGN KEY'; |
|
1752 | |||
1753 | 11 | $referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) . |
|
1754 | 11 | ' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')'; |
|
1755 | } |
||
1756 | 14 | $query .= ' '.$columnList.$referencesClause; |
|
1757 | |||
1758 | 14 | return $query; |
|
1759 | } |
||
1760 | |||
1761 | /** |
||
1762 | * Returns the SQL to create an index on a table on this platform. |
||
1763 | * |
||
1764 | * @param \Doctrine\DBAL\Schema\Index $index |
||
1765 | * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the index is to be created. |
||
1766 | * |
||
1767 | * @return string |
||
1768 | * |
||
1769 | * @throws \InvalidArgumentException |
||
1770 | */ |
||
1771 | 135 | public function getCreateIndexSQL(Index $index, $table) |
|
1792 | |||
1793 | /** |
||
1794 | * Adds condition for partial index. |
||
1795 | * |
||
1796 | * @param \Doctrine\DBAL\Schema\Index $index |
||
1797 | * |
||
1798 | * @return string |
||
1799 | */ |
||
1800 | 158 | protected function getPartialIndexSQL(Index $index) |
|
1808 | |||
1809 | /** |
||
1810 | * Adds additional flags for index generation. |
||
1811 | * |
||
1812 | * @param \Doctrine\DBAL\Schema\Index $index |
||
1813 | * |
||
1814 | * @return string |
||
1815 | */ |
||
1816 | 60 | protected function getCreateIndexSQLFlags(Index $index) |
|
1820 | |||
1821 | /** |
||
1822 | * Returns the SQL to create an unnamed primary key constraint. |
||
1823 | * |
||
1824 | * @param \Doctrine\DBAL\Schema\Index $index |
||
1825 | * @param \Doctrine\DBAL\Schema\Table|string $table |
||
1826 | * |
||
1827 | * @return string |
||
1828 | */ |
||
1829 | 12 | public function getCreatePrimaryKeySQL(Index $index, $table) |
|
1833 | |||
1834 | /** |
||
1835 | * Returns the SQL to create a named schema. |
||
1836 | * |
||
1837 | * @param string $schemaName |
||
1838 | * |
||
1839 | * @return string |
||
1840 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1841 | */ |
||
1842 | 9 | public function getCreateSchemaSQL($schemaName) |
|
1846 | |||
1847 | /** |
||
1848 | * Quotes a string so that it can be safely used as a table or column name, |
||
1849 | * even if it is a reserved word of the platform. This also detects identifier |
||
1850 | * chains separated by dot and quotes them independently. |
||
1851 | * |
||
1852 | * NOTE: Just because you CAN use quoted identifiers doesn't mean |
||
1853 | * you SHOULD use them. In general, they end up causing way more |
||
1854 | * problems than they solve. |
||
1855 | * |
||
1856 | * @param string $str The identifier name to be quoted. |
||
1857 | * |
||
1858 | * @return string The quoted identifier string. |
||
1859 | */ |
||
1860 | 348 | public function quoteIdentifier($str) |
|
1870 | |||
1871 | /** |
||
1872 | * Quotes a single identifier (no dot chain separation). |
||
1873 | * |
||
1874 | * @param string $str The identifier name to be quoted. |
||
1875 | * |
||
1876 | * @return string The quoted identifier string. |
||
1877 | */ |
||
1878 | 318 | public function quoteSingleIdentifier($str) |
|
1884 | |||
1885 | /** |
||
1886 | * Returns the SQL to create a new foreign key. |
||
1887 | * |
||
1888 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key constraint. |
||
1889 | * @param \Doctrine\DBAL\Schema\Table|string $table The name of the table on which the foreign key is to be created. |
||
1890 | * |
||
1891 | * @return string |
||
1892 | */ |
||
1893 | 67 | public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) |
|
1903 | |||
1904 | /** |
||
1905 | * Gets the SQL statements for altering an existing table. |
||
1906 | * |
||
1907 | * This method returns an array of SQL statements, since some platforms need several statements. |
||
1908 | * |
||
1909 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
1910 | * |
||
1911 | * @return array |
||
1912 | * |
||
1913 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
1914 | */ |
||
1915 | public function getAlterTableSQL(TableDiff $diff) |
||
1919 | |||
1920 | /** |
||
1921 | * @param \Doctrine\DBAL\Schema\Column $column |
||
1922 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
1923 | * @param array $columnSql |
||
1924 | * |
||
1925 | * @return boolean |
||
1926 | */ |
||
1927 | 86 | View Code Duplication | protected function onSchemaAlterTableAddColumn(Column $column, TableDiff $diff, &$columnSql) |
1944 | |||
1945 | /** |
||
1946 | * @param \Doctrine\DBAL\Schema\Column $column |
||
1947 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
1948 | * @param array $columnSql |
||
1949 | * |
||
1950 | * @return boolean |
||
1951 | */ |
||
1952 | 69 | View Code Duplication | protected function onSchemaAlterTableRemoveColumn(Column $column, TableDiff $diff, &$columnSql) |
1969 | |||
1970 | /** |
||
1971 | * @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff |
||
1972 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
1973 | * @param array $columnSql |
||
1974 | * |
||
1975 | * @return boolean |
||
1976 | */ |
||
1977 | 168 | View Code Duplication | protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiff, TableDiff $diff, &$columnSql) |
1994 | |||
1995 | /** |
||
1996 | * @param string $oldColumnName |
||
1997 | * @param \Doctrine\DBAL\Schema\Column $column |
||
1998 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
1999 | * @param array $columnSql |
||
2000 | * |
||
2001 | * @return boolean |
||
2002 | */ |
||
2003 | 68 | View Code Duplication | protected function onSchemaAlterTableRenameColumn($oldColumnName, Column $column, TableDiff $diff, &$columnSql) |
2020 | |||
2021 | /** |
||
2022 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
2023 | * @param array $sql |
||
2024 | * |
||
2025 | * @return boolean |
||
2026 | */ |
||
2027 | 315 | View Code Duplication | protected function onSchemaAlterTable(TableDiff $diff, &$sql) |
2044 | |||
2045 | /** |
||
2046 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
2047 | * |
||
2048 | * @return array |
||
2049 | */ |
||
2050 | 283 | protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
2073 | |||
2074 | /** |
||
2075 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
2076 | * |
||
2077 | * @return array |
||
2078 | */ |
||
2079 | 283 | protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) |
|
2115 | |||
2116 | /** |
||
2117 | * Returns the SQL for renaming an index on a table. |
||
2118 | * |
||
2119 | * @param string $oldIndexName The name of the index to rename from. |
||
2120 | * @param \Doctrine\DBAL\Schema\Index $index The definition of the index to rename to. |
||
2121 | * @param string $tableName The table to rename the given index on. |
||
2122 | * |
||
2123 | * @return array The sequence of SQL statements for renaming the given index. |
||
2124 | */ |
||
2125 | 5 | protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) |
|
2132 | |||
2133 | /** |
||
2134 | * Common code for alter table statement generation that updates the changed Index and Foreign Key definitions. |
||
2135 | * |
||
2136 | * @param \Doctrine\DBAL\Schema\TableDiff $diff |
||
2137 | * |
||
2138 | * @return array |
||
2139 | */ |
||
2140 | protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff) |
||
2144 | |||
2145 | /** |
||
2146 | * Gets declaration of a number of fields in bulk. |
||
2147 | * |
||
2148 | * @param array $fields A multidimensional associative array. |
||
2149 | * The first dimension determines the field name, while the second |
||
2150 | * dimension is keyed with the name of the properties |
||
2151 | * of the field being declared as array indexes. Currently, the types |
||
2152 | * of supported field properties are as follows: |
||
2153 | * |
||
2154 | * length |
||
2155 | * Integer value that determines the maximum length of the text |
||
2156 | * field. If this argument is missing the field should be |
||
2157 | * declared to have the longest length allowed by the DBMS. |
||
2158 | * |
||
2159 | * default |
||
2160 | * Text value to be used as default for this field. |
||
2161 | * |
||
2162 | * notnull |
||
2163 | * Boolean flag that indicates whether this field is constrained |
||
2164 | * to not be set to null. |
||
2165 | * charset |
||
2166 | * Text value with the default CHARACTER SET for this field. |
||
2167 | * collation |
||
2168 | * Text value with the default COLLATION for this field. |
||
2169 | * unique |
||
2170 | * unique constraint |
||
2171 | * |
||
2172 | * @return string |
||
2173 | */ |
||
2174 | 334 | public function getColumnDeclarationListSQL(array $fields) |
|
2184 | |||
2185 | /** |
||
2186 | * Obtains DBMS specific SQL code portion needed to declare a generic type |
||
2187 | * field to be used in statements like CREATE TABLE. |
||
2188 | * |
||
2189 | * @param string $name The name the field to be declared. |
||
2190 | * @param array $field An associative array with the name of the properties |
||
2191 | * of the field being declared as array indexes. Currently, the types |
||
2192 | * of supported field properties are as follows: |
||
2193 | * |
||
2194 | * length |
||
2195 | * Integer value that determines the maximum length of the text |
||
2196 | * field. If this argument is missing the field should be |
||
2197 | * declared to have the longest length allowed by the DBMS. |
||
2198 | * |
||
2199 | * default |
||
2200 | * Text value to be used as default for this field. |
||
2201 | * |
||
2202 | * notnull |
||
2203 | * Boolean flag that indicates whether this field is constrained |
||
2204 | * to not be set to null. |
||
2205 | * charset |
||
2206 | * Text value with the default CHARACTER SET for this field. |
||
2207 | * collation |
||
2208 | * Text value with the default COLLATION for this field. |
||
2209 | * unique |
||
2210 | * unique constraint |
||
2211 | * check |
||
2212 | * column check constraint |
||
2213 | * columnDefinition |
||
2214 | * a string that defines the complete column |
||
2215 | * |
||
2216 | * @return string DBMS specific SQL code portion that should be used to declare the column. |
||
2217 | */ |
||
2218 | 364 | public function getColumnDeclarationSQL($name, array $field) |
|
2249 | |||
2250 | /** |
||
2251 | * Returns the SQL snippet that declares a floating point column of arbitrary precision. |
||
2252 | * |
||
2253 | * @param array $columnDef |
||
2254 | * |
||
2255 | * @return string |
||
2256 | */ |
||
2257 | 120 | public function getDecimalTypeDeclarationSQL(array $columnDef) |
|
2266 | |||
2267 | /** |
||
2268 | * Obtains DBMS specific SQL code portion needed to set a default value |
||
2269 | * declaration to be used in statements like CREATE TABLE. |
||
2270 | * |
||
2271 | * @param array $field The field definition array. |
||
2272 | * |
||
2273 | * @return string DBMS specific SQL code portion needed to set a default value. |
||
2274 | */ |
||
2275 | 423 | public function getDefaultValueDeclarationSQL($field) |
|
2276 | { |
||
2277 | 423 | $default = empty($field['notnull']) ? ' DEFAULT NULL' : ''; |
|
2278 | |||
2279 | 423 | if (isset($field['default'])) { |
|
2280 | 77 | $default = " DEFAULT '".$field['default']."'"; |
|
2281 | 77 | if (isset($field['type'])) { |
|
2282 | 77 | if (in_array((string) $field['type'], ["Integer", "BigInt", "SmallInt"])) { |
|
2283 | 20 | $default = " DEFAULT ".$field['default']; |
|
2284 | 59 | View Code Duplication | } elseif (in_array((string) $field['type'], ['DateTime', 'DateTimeTz']) && $field['default'] == $this->getCurrentTimestampSQL()) { |
2285 | 13 | $default = " DEFAULT ".$this->getCurrentTimestampSQL(); |
|
2286 | 46 | } elseif ((string) $field['type'] == 'Time' && $field['default'] == $this->getCurrentTimeSQL()) { |
|
2287 | $default = " DEFAULT ".$this->getCurrentTimeSQL(); |
||
2288 | 46 | } elseif ((string) $field['type'] == 'Date' && $field['default'] == $this->getCurrentDateSQL()) { |
|
2289 | 13 | $default = " DEFAULT ".$this->getCurrentDateSQL(); |
|
2290 | 33 | View Code Duplication | } elseif ((string) $field['type'] == 'Boolean') { |
2291 | 13 | $default = " DEFAULT '" . $this->convertBooleans($field['default']) . "'"; |
|
2292 | } |
||
2293 | } |
||
2294 | } |
||
2295 | |||
2296 | 423 | return $default; |
|
2297 | } |
||
2298 | |||
2299 | /** |
||
2300 | * Obtains DBMS specific SQL code portion needed to set a CHECK constraint |
||
2301 | * declaration to be used in statements like CREATE TABLE. |
||
2302 | * |
||
2303 | * @param array $definition The check definition. |
||
2304 | * |
||
2305 | * @return string DBMS specific SQL code portion needed to set a CHECK constraint. |
||
2306 | */ |
||
2307 | 117 | public function getCheckDeclarationSQL(array $definition) |
|
2326 | |||
2327 | /** |
||
2328 | * Obtains DBMS specific SQL code portion needed to set a unique |
||
2329 | * constraint declaration to be used in statements like CREATE TABLE. |
||
2330 | * |
||
2331 | * @param string $name The name of the unique constraint. |
||
2332 | * @param \Doctrine\DBAL\Schema\Index $index The index definition. |
||
2333 | * |
||
2334 | * @return string DBMS specific SQL code portion needed to set a constraint. |
||
2335 | * |
||
2336 | * @throws \InvalidArgumentException |
||
2337 | */ |
||
2338 | 24 | View Code Duplication | public function getUniqueConstraintDeclarationSQL($name, Index $index) |
2351 | |||
2352 | /** |
||
2353 | * Obtains DBMS specific SQL code portion needed to set an index |
||
2354 | * declaration to be used in statements like CREATE TABLE. |
||
2355 | * |
||
2356 | * @param string $name The name of the index. |
||
2357 | * @param \Doctrine\DBAL\Schema\Index $index The index definition. |
||
2358 | * |
||
2359 | * @return string DBMS specific SQL code portion needed to set an index. |
||
2360 | * |
||
2361 | * @throws \InvalidArgumentException |
||
2362 | */ |
||
2363 | 36 | View Code Duplication | public function getIndexDeclarationSQL($name, Index $index) |
2376 | |||
2377 | /** |
||
2378 | * Obtains SQL code portion needed to create a custom column, |
||
2379 | * e.g. when a field has the "columnDefinition" keyword. |
||
2380 | * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate. |
||
2381 | * |
||
2382 | * @param array $columnDef |
||
2383 | * |
||
2384 | * @return string |
||
2385 | */ |
||
2386 | 17 | public function getCustomTypeDeclarationSQL(array $columnDef) |
|
2390 | |||
2391 | /** |
||
2392 | * Obtains DBMS specific SQL code portion needed to set an index |
||
2393 | * declaration to be used in statements like CREATE TABLE. |
||
2394 | * |
||
2395 | * @param array $fields |
||
2396 | * |
||
2397 | * @return string |
||
2398 | */ |
||
2399 | 222 | public function getIndexFieldDeclarationListSQL(array $fields) |
|
2413 | |||
2414 | /** |
||
2415 | * Returns the required SQL string that fits between CREATE ... TABLE |
||
2416 | * to create the table as a temporary table. |
||
2417 | * |
||
2418 | * Should be overridden in driver classes to return the correct string for the |
||
2419 | * specific database type. |
||
2420 | * |
||
2421 | * The default is to return the string "TEMPORARY" - this will result in a |
||
2422 | * SQL error for any database that does not support temporary tables, or that |
||
2423 | * requires a different SQL command from "CREATE TEMPORARY TABLE". |
||
2424 | * |
||
2425 | * @return string The string required to be placed between "CREATE" and "TABLE" |
||
2426 | * to generate a temporary table, if possible. |
||
2427 | */ |
||
2428 | public function getTemporaryTableSQL() |
||
2432 | |||
2433 | /** |
||
2434 | * Some vendors require temporary table names to be qualified specially. |
||
2435 | * |
||
2436 | * @param string $tableName |
||
2437 | * |
||
2438 | * @return string |
||
2439 | */ |
||
2440 | public function getTemporaryTableName($tableName) |
||
2444 | |||
2445 | /** |
||
2446 | * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
2447 | * of a field declaration to be used in statements like CREATE TABLE. |
||
2448 | * |
||
2449 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey |
||
2450 | * |
||
2451 | * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
2452 | * of a field declaration. |
||
2453 | */ |
||
2454 | 101 | public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
2461 | |||
2462 | /** |
||
2463 | * Returns the FOREIGN KEY query section dealing with non-standard options |
||
2464 | * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... |
||
2465 | * |
||
2466 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey The foreign key definition. |
||
2467 | * |
||
2468 | * @return string |
||
2469 | */ |
||
2470 | 85 | public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey) |
|
2482 | |||
2483 | /** |
||
2484 | * Returns the given referential action in uppercase if valid, otherwise throws an exception. |
||
2485 | * |
||
2486 | * @param string $action The foreign key referential action. |
||
2487 | * |
||
2488 | * @return string |
||
2489 | * |
||
2490 | * @throws \InvalidArgumentException if unknown referential action given |
||
2491 | */ |
||
2492 | 106 | View Code Duplication | public function getForeignKeyReferentialActionSQL($action) |
2506 | |||
2507 | /** |
||
2508 | * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint |
||
2509 | * of a field declaration to be used in statements like CREATE TABLE. |
||
2510 | * |
||
2511 | * @param \Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey |
||
2512 | * |
||
2513 | * @return string |
||
2514 | * |
||
2515 | * @throws \InvalidArgumentException |
||
2516 | */ |
||
2517 | 61 | public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey) |
|
2542 | |||
2543 | /** |
||
2544 | * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
2545 | * of a field declaration to be used in statements like CREATE TABLE. |
||
2546 | * |
||
2547 | * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint |
||
2548 | * of a field declaration. |
||
2549 | */ |
||
2550 | public function getUniqueFieldDeclarationSQL() |
||
2554 | |||
2555 | /** |
||
2556 | * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET |
||
2557 | * of a field declaration to be used in statements like CREATE TABLE. |
||
2558 | * |
||
2559 | * @param string $charset The name of the charset. |
||
2560 | * |
||
2561 | * @return string DBMS specific SQL code portion needed to set the CHARACTER SET |
||
2562 | * of a field declaration. |
||
2563 | */ |
||
2564 | public function getColumnCharsetDeclarationSQL($charset) |
||
2568 | |||
2569 | /** |
||
2570 | * Obtains DBMS specific SQL code portion needed to set the COLLATION |
||
2571 | * of a field declaration to be used in statements like CREATE TABLE. |
||
2572 | * |
||
2573 | * @param string $collation The name of the collation. |
||
2574 | * |
||
2575 | * @return string DBMS specific SQL code portion needed to set the COLLATION |
||
2576 | * of a field declaration. |
||
2577 | */ |
||
2578 | 1 | public function getColumnCollationDeclarationSQL($collation) |
|
2582 | |||
2583 | /** |
||
2584 | * Whether the platform prefers sequences for ID generation. |
||
2585 | * Subclasses should override this method to return TRUE if they prefer sequences. |
||
2586 | * |
||
2587 | * @return boolean |
||
2588 | */ |
||
2589 | 5 | public function prefersSequences() |
|
2593 | |||
2594 | /** |
||
2595 | * Whether the platform prefers identity columns (eg. autoincrement) for ID generation. |
||
2596 | * Subclasses should override this method to return TRUE if they prefer identity columns. |
||
2597 | * |
||
2598 | * @return boolean |
||
2599 | */ |
||
2600 | 5 | public function prefersIdentityColumns() |
|
2604 | |||
2605 | /** |
||
2606 | * Some platforms need the boolean values to be converted. |
||
2607 | * |
||
2608 | * The default conversion in this implementation converts to integers (false => 0, true => 1). |
||
2609 | * |
||
2610 | * Note: if the input is not a boolean the original input might be returned. |
||
2611 | * |
||
2612 | * There are two contexts when converting booleans: Literals and Prepared Statements. |
||
2613 | * This method should handle the literal case |
||
2614 | * |
||
2615 | * @param mixed $item A boolean or an array of them. |
||
2616 | * |
||
2617 | * @return mixed A boolean database value or an array of them. |
||
2618 | */ |
||
2619 | 20 | public function convertBooleans($item) |
|
2633 | |||
2634 | /** |
||
2635 | * Some platforms have boolean literals that needs to be correctly converted |
||
2636 | * |
||
2637 | * The default conversion tries to convert value into bool "(bool)$item" |
||
2638 | * |
||
2639 | * @param mixed $item |
||
2640 | * |
||
2641 | * @return bool|null |
||
2642 | */ |
||
2643 | 40 | public function convertFromBoolean($item) |
|
2647 | |||
2648 | /** |
||
2649 | * This method should handle the prepared statements case. When there is no |
||
2650 | * distinction, it's OK to use the same method. |
||
2651 | * |
||
2652 | * Note: if the input is not a boolean the original input might be returned. |
||
2653 | * |
||
2654 | * @param mixed $item A boolean or an array of them. |
||
2655 | * |
||
2656 | * @return mixed A boolean database value or an array of them. |
||
2657 | */ |
||
2658 | 7 | public function convertBooleansToDatabaseValue($item) |
|
2662 | |||
2663 | /** |
||
2664 | * Returns the SQL specific for the platform to get the current date. |
||
2665 | * |
||
2666 | * @return string |
||
2667 | */ |
||
2668 | 9 | public function getCurrentDateSQL() |
|
2672 | |||
2673 | /** |
||
2674 | * Returns the SQL specific for the platform to get the current time. |
||
2675 | * |
||
2676 | * @return string |
||
2677 | */ |
||
2678 | public function getCurrentTimeSQL() |
||
2682 | |||
2683 | /** |
||
2684 | * Returns the SQL specific for the platform to get the current timestamp |
||
2685 | * |
||
2686 | * @return string |
||
2687 | */ |
||
2688 | 15 | public function getCurrentTimestampSQL() |
|
2692 | |||
2693 | /** |
||
2694 | * Returns the SQL for a given transaction isolation level Connection constant. |
||
2695 | * |
||
2696 | * @param integer $level |
||
2697 | * |
||
2698 | * @return string |
||
2699 | * |
||
2700 | * @throws \InvalidArgumentException |
||
2701 | */ |
||
2702 | 9 | protected function _getTransactionIsolationLevelSQL($level) |
|
2717 | |||
2718 | /** |
||
2719 | * @return string |
||
2720 | * |
||
2721 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2722 | */ |
||
2723 | 1 | public function getListDatabasesSQL() |
|
2727 | |||
2728 | /** |
||
2729 | * Returns the SQL statement for retrieving the namespaces defined in the database. |
||
2730 | * |
||
2731 | * @return string |
||
2732 | * |
||
2733 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2734 | */ |
||
2735 | public function getListNamespacesSQL() |
||
2739 | |||
2740 | /** |
||
2741 | * @param string $database |
||
2742 | * |
||
2743 | * @return string |
||
2744 | * |
||
2745 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2746 | */ |
||
2747 | public function getListSequencesSQL($database) |
||
2751 | |||
2752 | /** |
||
2753 | * @param string $table |
||
2754 | * |
||
2755 | * @return string |
||
2756 | * |
||
2757 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2758 | */ |
||
2759 | public function getListTableConstraintsSQL($table) |
||
2763 | |||
2764 | /** |
||
2765 | * @param string $table |
||
2766 | * @param string|null $database |
||
2767 | * |
||
2768 | * @return string |
||
2769 | * |
||
2770 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2771 | */ |
||
2772 | public function getListTableColumnsSQL($table, $database = null) |
||
2776 | |||
2777 | /** |
||
2778 | * @return string |
||
2779 | * |
||
2780 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2781 | */ |
||
2782 | public function getListTablesSQL() |
||
2786 | |||
2787 | /** |
||
2788 | * @return string |
||
2789 | * |
||
2790 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2791 | */ |
||
2792 | public function getListUsersSQL() |
||
2796 | |||
2797 | /** |
||
2798 | * Returns the SQL to list all views of a database or user. |
||
2799 | * |
||
2800 | * @param string $database |
||
2801 | * |
||
2802 | * @return string |
||
2803 | * |
||
2804 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2805 | */ |
||
2806 | public function getListViewsSQL($database) |
||
2810 | |||
2811 | /** |
||
2812 | * Returns the list of indexes for the current database. |
||
2813 | * |
||
2814 | * The current database parameter is optional but will always be passed |
||
2815 | * when using the SchemaManager API and is the database the given table is in. |
||
2816 | * |
||
2817 | * Attention: Some platforms only support currentDatabase when they |
||
2818 | * are connected with that database. Cross-database information schema |
||
2819 | * requests may be impossible. |
||
2820 | * |
||
2821 | * @param string $table |
||
2822 | * @param string $currentDatabase |
||
2823 | * |
||
2824 | * @return string |
||
2825 | * |
||
2826 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2827 | */ |
||
2828 | public function getListTableIndexesSQL($table, $currentDatabase = null) |
||
2832 | |||
2833 | /** |
||
2834 | * @param string $table |
||
2835 | * |
||
2836 | * @return string |
||
2837 | * |
||
2838 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2839 | */ |
||
2840 | public function getListTableForeignKeysSQL($table) |
||
2844 | |||
2845 | /** |
||
2846 | * @param string $name |
||
2847 | * @param string $sql |
||
2848 | * |
||
2849 | * @return string |
||
2850 | * |
||
2851 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2852 | */ |
||
2853 | public function getCreateViewSQL($name, $sql) |
||
2857 | |||
2858 | /** |
||
2859 | * @param string $name |
||
2860 | * |
||
2861 | * @return string |
||
2862 | * |
||
2863 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2864 | */ |
||
2865 | public function getDropViewSQL($name) |
||
2869 | |||
2870 | /** |
||
2871 | * Returns the SQL snippet to drop an existing sequence. |
||
2872 | * |
||
2873 | * @param Sequence|string $sequence |
||
2874 | * |
||
2875 | * @return string |
||
2876 | * |
||
2877 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2878 | */ |
||
2879 | public function getDropSequenceSQL($sequence) |
||
2883 | |||
2884 | /** |
||
2885 | * @param string $sequenceName |
||
2886 | * |
||
2887 | * @return string |
||
2888 | * |
||
2889 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2890 | */ |
||
2891 | public function getSequenceNextValSQL($sequenceName) |
||
2895 | |||
2896 | /** |
||
2897 | * Returns the SQL to create a new database. |
||
2898 | * |
||
2899 | * @param string $database The name of the database that should be created. |
||
2900 | * |
||
2901 | * @return string |
||
2902 | * |
||
2903 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2904 | */ |
||
2905 | 1 | public function getCreateDatabaseSQL($database) |
|
2909 | |||
2910 | /** |
||
2911 | * Returns the SQL to set the transaction isolation level. |
||
2912 | * |
||
2913 | * @param integer $level |
||
2914 | * |
||
2915 | * @return string |
||
2916 | * |
||
2917 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2918 | */ |
||
2919 | public function getSetTransactionIsolationSQL($level) |
||
2923 | |||
2924 | /** |
||
2925 | * Obtains DBMS specific SQL to be used to create datetime fields in |
||
2926 | * statements like CREATE TABLE. |
||
2927 | * |
||
2928 | * @param array $fieldDeclaration |
||
2929 | * |
||
2930 | * @return string |
||
2931 | * |
||
2932 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2933 | */ |
||
2934 | public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
2938 | |||
2939 | /** |
||
2940 | * Obtains DBMS specific SQL to be used to create datetime with timezone offset fields. |
||
2941 | * |
||
2942 | * @param array $fieldDeclaration |
||
2943 | * |
||
2944 | * @return string |
||
2945 | */ |
||
2946 | 15 | public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
|
2950 | |||
2951 | |||
2952 | /** |
||
2953 | * Obtains DBMS specific SQL to be used to create date fields in statements |
||
2954 | * like CREATE TABLE. |
||
2955 | * |
||
2956 | * @param array $fieldDeclaration |
||
2957 | * |
||
2958 | * @return string |
||
2959 | * |
||
2960 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2961 | */ |
||
2962 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
||
2966 | |||
2967 | /** |
||
2968 | * Obtains DBMS specific SQL to be used to create time fields in statements |
||
2969 | * like CREATE TABLE. |
||
2970 | * |
||
2971 | * @param array $fieldDeclaration |
||
2972 | * |
||
2973 | * @return string |
||
2974 | * |
||
2975 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
2976 | */ |
||
2977 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
2981 | |||
2982 | /** |
||
2983 | * @param array $fieldDeclaration |
||
2984 | * |
||
2985 | * @return string |
||
2986 | */ |
||
2987 | 99 | public function getFloatDeclarationSQL(array $fieldDeclaration) |
|
2991 | |||
2992 | /** |
||
2993 | * Gets the default transaction isolation level of the platform. |
||
2994 | * |
||
2995 | * @return integer The default isolation level. |
||
2996 | * |
||
2997 | * @see Doctrine\DBAL\Connection\TRANSACTION_* constants. |
||
2998 | */ |
||
2999 | public function getDefaultTransactionIsolationLevel() |
||
3003 | |||
3004 | /* supports*() methods */ |
||
3005 | |||
3006 | /** |
||
3007 | * Whether the platform supports sequences. |
||
3008 | * |
||
3009 | * @return boolean |
||
3010 | */ |
||
3011 | 6 | public function supportsSequences() |
|
3015 | |||
3016 | /** |
||
3017 | * Whether the platform supports identity columns. |
||
3018 | * |
||
3019 | * Identity columns are columns that receive an auto-generated value from the |
||
3020 | * database on insert of a row. |
||
3021 | * |
||
3022 | * @return boolean |
||
3023 | */ |
||
3024 | 1 | public function supportsIdentityColumns() |
|
3028 | |||
3029 | /** |
||
3030 | * Whether the platform emulates identity columns through sequences. |
||
3031 | * |
||
3032 | * Some platforms that do not support identity columns natively |
||
3033 | * but support sequences can emulate identity columns by using |
||
3034 | * sequences. |
||
3035 | * |
||
3036 | * @return boolean |
||
3037 | */ |
||
3038 | 12 | public function usesSequenceEmulatedIdentityColumns() |
|
3042 | |||
3043 | /** |
||
3044 | * Returns the name of the sequence for a particular identity column in a particular table. |
||
3045 | * |
||
3046 | * @param string $tableName The name of the table to return the sequence name for. |
||
3047 | * @param string $columnName The name of the identity column in the table to return the sequence name for. |
||
3048 | * |
||
3049 | * @return string |
||
3050 | * |
||
3051 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
3052 | * |
||
3053 | * @see usesSequenceEmulatedIdentityColumns |
||
3054 | */ |
||
3055 | 11 | public function getIdentitySequenceName($tableName, $columnName) |
|
3059 | |||
3060 | /** |
||
3061 | * Whether the platform supports indexes. |
||
3062 | * |
||
3063 | * @return boolean |
||
3064 | */ |
||
3065 | 4 | public function supportsIndexes() |
|
3069 | |||
3070 | /** |
||
3071 | * Whether the platform supports partial indexes. |
||
3072 | * |
||
3073 | * @return boolean |
||
3074 | */ |
||
3075 | 126 | public function supportsPartialIndexes() |
|
3079 | |||
3080 | /** |
||
3081 | * Whether the platform supports altering tables. |
||
3082 | * |
||
3083 | * @return boolean |
||
3084 | */ |
||
3085 | 5 | public function supportsAlterTable() |
|
3089 | |||
3090 | /** |
||
3091 | * Whether the platform supports transactions. |
||
3092 | * |
||
3093 | * @return boolean |
||
3094 | */ |
||
3095 | 4 | public function supportsTransactions() |
|
3099 | |||
3100 | /** |
||
3101 | * Whether the platform supports savepoints. |
||
3102 | * |
||
3103 | * @return boolean |
||
3104 | */ |
||
3105 | 20 | public function supportsSavepoints() |
|
3109 | |||
3110 | /** |
||
3111 | * Whether the platform supports releasing savepoints. |
||
3112 | * |
||
3113 | * @return boolean |
||
3114 | */ |
||
3115 | 5 | public function supportsReleaseSavepoints() |
|
3119 | |||
3120 | /** |
||
3121 | * Whether the platform supports primary key constraints. |
||
3122 | * |
||
3123 | * @return boolean |
||
3124 | */ |
||
3125 | 4 | public function supportsPrimaryConstraints() |
|
3129 | |||
3130 | /** |
||
3131 | * Whether the platform supports foreign key constraints. |
||
3132 | * |
||
3133 | * @return boolean |
||
3134 | */ |
||
3135 | 370 | public function supportsForeignKeyConstraints() |
|
3139 | |||
3140 | /** |
||
3141 | * Whether this platform supports onUpdate in foreign key constraints. |
||
3142 | * |
||
3143 | * @return boolean |
||
3144 | */ |
||
3145 | 89 | public function supportsForeignKeyOnUpdate() |
|
3149 | |||
3150 | /** |
||
3151 | * Whether the platform supports database schemas. |
||
3152 | * |
||
3153 | * @return boolean |
||
3154 | */ |
||
3155 | 10 | public function supportsSchemas() |
|
3159 | |||
3160 | /** |
||
3161 | * Whether this platform can emulate schemas. |
||
3162 | * |
||
3163 | * Platforms that either support or emulate schemas don't automatically |
||
3164 | * filter a schema for the namespaced elements in {@link |
||
3165 | * AbstractManager#createSchema}. |
||
3166 | * |
||
3167 | * @return boolean |
||
3168 | */ |
||
3169 | 4 | public function canEmulateSchemas() |
|
3173 | |||
3174 | /** |
||
3175 | * Returns the default schema name. |
||
3176 | * |
||
3177 | * @return string |
||
3178 | * |
||
3179 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
3180 | */ |
||
3181 | public function getDefaultSchemaName() |
||
3185 | |||
3186 | /** |
||
3187 | * Whether this platform supports create database. |
||
3188 | * |
||
3189 | * Some databases don't allow to create and drop databases at all or only with certain tools. |
||
3190 | * |
||
3191 | * @return boolean |
||
3192 | */ |
||
3193 | 4 | public function supportsCreateDropDatabase() |
|
3197 | |||
3198 | /** |
||
3199 | * Whether the platform supports getting the affected rows of a recent update/delete type query. |
||
3200 | * |
||
3201 | * @return boolean |
||
3202 | */ |
||
3203 | 4 | public function supportsGettingAffectedRows() |
|
3207 | |||
3208 | /** |
||
3209 | * Whether this platform support to add inline column comments as postfix. |
||
3210 | * |
||
3211 | * @return boolean |
||
3212 | */ |
||
3213 | 161 | public function supportsInlineColumnComments() |
|
3217 | |||
3218 | /** |
||
3219 | * Whether this platform support the proprietary syntax "COMMENT ON asset". |
||
3220 | * |
||
3221 | * @return boolean |
||
3222 | */ |
||
3223 | 229 | public function supportsCommentOnStatement() |
|
3227 | |||
3228 | /** |
||
3229 | * Does this platform have native guid type. |
||
3230 | * |
||
3231 | * @return boolean |
||
3232 | */ |
||
3233 | 249 | public function hasNativeGuidType() |
|
3237 | |||
3238 | /** |
||
3239 | * Does this platform have native JSON type. |
||
3240 | * |
||
3241 | * @return boolean |
||
3242 | */ |
||
3243 | 616 | public function hasNativeJsonType() |
|
3247 | |||
3248 | /** |
||
3249 | * @deprecated |
||
3250 | * @todo Remove in 3.0 |
||
3251 | */ |
||
3252 | public function getIdentityColumnNullInsertSQL() |
||
3256 | |||
3257 | /** |
||
3258 | * Whether this platform supports views. |
||
3259 | * |
||
3260 | * @return boolean |
||
3261 | */ |
||
3262 | 1 | public function supportsViews() |
|
3266 | |||
3267 | /** |
||
3268 | * Does this platform support column collation? |
||
3269 | * |
||
3270 | * @return boolean |
||
3271 | */ |
||
3272 | public function supportsColumnCollation() |
||
3276 | |||
3277 | /** |
||
3278 | * Gets the format string, as accepted by the date() function, that describes |
||
3279 | * the format of a stored datetime value of this platform. |
||
3280 | * |
||
3281 | * @return string The format string. |
||
3282 | */ |
||
3283 | 18 | public function getDateTimeFormatString() |
|
3287 | |||
3288 | /** |
||
3289 | * Gets the format string, as accepted by the date() function, that describes |
||
3290 | * the format of a stored datetime with timezone value of this platform. |
||
3291 | * |
||
3292 | * @return string The format string. |
||
3293 | */ |
||
3294 | 8 | public function getDateTimeTzFormatString() |
|
3298 | |||
3299 | /** |
||
3300 | * Gets the format string, as accepted by the date() function, that describes |
||
3301 | * the format of a stored date value of this platform. |
||
3302 | * |
||
3303 | * @return string The format string. |
||
3304 | */ |
||
3305 | 7 | public function getDateFormatString() |
|
3309 | |||
3310 | /** |
||
3311 | * Gets the format string, as accepted by the date() function, that describes |
||
3312 | * the format of a stored time value of this platform. |
||
3313 | * |
||
3314 | * @return string The format string. |
||
3315 | */ |
||
3316 | 6 | public function getTimeFormatString() |
|
3320 | |||
3321 | /** |
||
3322 | * Adds an driver-specific LIMIT clause to the query. |
||
3323 | * |
||
3324 | * @param string $query |
||
3325 | * @param integer|null $limit |
||
3326 | * @param integer|null $offset |
||
3327 | * |
||
3328 | * @return string |
||
3329 | * |
||
3330 | * @throws DBALException |
||
3331 | */ |
||
3332 | 113 | final public function modifyLimitQuery($query, $limit, $offset = null) |
|
3351 | |||
3352 | /** |
||
3353 | * Adds an driver-specific LIMIT clause to the query. |
||
3354 | * |
||
3355 | * @param string $query |
||
3356 | * @param integer|null $limit |
||
3357 | * @param integer|null $offset |
||
3358 | * |
||
3359 | * @return string |
||
3360 | */ |
||
3361 | 17 | protected function doModifyLimitQuery($query, $limit, $offset) |
|
3373 | |||
3374 | /** |
||
3375 | * Whether the database platform support offsets in modify limit clauses. |
||
3376 | * |
||
3377 | * @return boolean |
||
3378 | */ |
||
3379 | 17 | public function supportsLimitOffset() |
|
3383 | |||
3384 | /** |
||
3385 | * Gets the character casing of a column in an SQL result set of this platform. |
||
3386 | * |
||
3387 | * @param string $column The column name for which to get the correct character casing. |
||
3388 | * |
||
3389 | * @return string The column name in the character casing used in SQL result sets. |
||
3390 | */ |
||
3391 | public function getSQLResultCasing($column) |
||
3395 | |||
3396 | /** |
||
3397 | * Makes any fixes to a name of a schema element (table, sequence, ...) that are required |
||
3398 | * by restrictions of the platform, like a maximum length. |
||
3399 | * |
||
3400 | * @param string $schemaElementName |
||
3401 | * |
||
3402 | * @return string |
||
3403 | */ |
||
3404 | public function fixSchemaElementName($schemaElementName) |
||
3408 | |||
3409 | /** |
||
3410 | * Maximum length of any given database identifier, like tables or column names. |
||
3411 | * |
||
3412 | * @return integer |
||
3413 | */ |
||
3414 | 13 | public function getMaxIdentifierLength() |
|
3418 | |||
3419 | /** |
||
3420 | * Returns the insert SQL for an empty insert statement. |
||
3421 | * |
||
3422 | * @param string $tableName |
||
3423 | * @param string $identifierColumnName |
||
3424 | * |
||
3425 | * @return string |
||
3426 | */ |
||
3427 | 1 | public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) |
|
3431 | |||
3432 | /** |
||
3433 | * Generates a Truncate Table SQL statement for a given table. |
||
3434 | * |
||
3435 | * Cascade is not supported on many platforms but would optionally cascade the truncate by |
||
3436 | * following the foreign keys. |
||
3437 | * |
||
3438 | * @param string $tableName |
||
3439 | * @param boolean $cascade |
||
3440 | * |
||
3441 | * @return string |
||
3442 | */ |
||
3443 | 2 | public function getTruncateTableSQL($tableName, $cascade = false) |
|
3449 | |||
3450 | /** |
||
3451 | * This is for test reasons, many vendors have special requirements for dummy statements. |
||
3452 | * |
||
3453 | * @return string |
||
3454 | */ |
||
3455 | 6 | public function getDummySelectSQL() |
|
3459 | |||
3460 | /** |
||
3461 | * Returns the SQL to create a new savepoint. |
||
3462 | * |
||
3463 | * @param string $savepoint |
||
3464 | * |
||
3465 | * @return string |
||
3466 | */ |
||
3467 | 1 | public function createSavePoint($savepoint) |
|
3471 | |||
3472 | /** |
||
3473 | * Returns the SQL to release a savepoint. |
||
3474 | * |
||
3475 | * @param string $savepoint |
||
3476 | * |
||
3477 | * @return string |
||
3478 | */ |
||
3479 | 1 | public function releaseSavePoint($savepoint) |
|
3483 | |||
3484 | /** |
||
3485 | * Returns the SQL to rollback a savepoint. |
||
3486 | * |
||
3487 | * @param string $savepoint |
||
3488 | * |
||
3489 | * @return string |
||
3490 | */ |
||
3491 | 1 | public function rollbackSavePoint($savepoint) |
|
3495 | |||
3496 | /** |
||
3497 | * Returns the keyword list instance of this platform. |
||
3498 | * |
||
3499 | * @return \Doctrine\DBAL\Platforms\Keywords\KeywordList |
||
3500 | * |
||
3501 | * @throws \Doctrine\DBAL\DBALException If no keyword list is specified. |
||
3502 | */ |
||
3503 | 954 | final public function getReservedKeywordsList() |
|
3521 | |||
3522 | /** |
||
3523 | * Returns the class name of the reserved keywords list. |
||
3524 | * |
||
3525 | * @return string |
||
3526 | * |
||
3527 | * @throws \Doctrine\DBAL\DBALException If not supported on this platform. |
||
3528 | */ |
||
3529 | protected function getReservedKeywordsClass() |
||
3533 | |||
3534 | /** |
||
3535 | * Quotes a literal string. |
||
3536 | * This method is NOT meant to fix SQL injections! |
||
3537 | * It is only meant to escape this platform's string literal |
||
3538 | * quote character inside the given literal string. |
||
3539 | * |
||
3540 | * @param string $str The literal string to be quoted. |
||
3541 | * |
||
3542 | * @return string The quoted literal string. |
||
3543 | */ |
||
3544 | 293 | public function quoteStringLiteral($str) |
|
3550 | |||
3551 | /** |
||
3552 | * Gets the character used for string literal quoting. |
||
3553 | * |
||
3554 | * @return string |
||
3555 | */ |
||
3556 | 309 | public function getStringLiteralQuoteCharacter() |
|
3560 | } |
||
3561 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.