1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Doctrine\DBAL\Platforms; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version. |
24
|
|
|
* |
25
|
|
|
* Differences to SQL Server 2005 and before are that a new DATETIME2 type was |
26
|
|
|
* introduced that has a higher precision. |
27
|
|
|
*/ |
28
|
|
|
class SQLServer2008Platform extends SQLServer2005Platform |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* {@inheritDoc} |
32
|
|
|
*/ |
33
|
130 |
|
public function getListTablesSQL() |
34
|
|
|
{ |
35
|
|
|
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams |
36
|
|
|
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication |
37
|
130 |
|
return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name"; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
*/ |
43
|
40 |
|
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
44
|
|
|
{ |
45
|
|
|
// 3 - microseconds precision length |
46
|
|
|
// http://msdn.microsoft.com/en-us/library/ms187819.aspx |
47
|
40 |
|
return 'DATETIME2(6)'; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritDoc} |
52
|
|
|
*/ |
53
|
38 |
|
public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
54
|
|
|
{ |
55
|
38 |
|
return 'DATE'; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritDoc} |
60
|
|
|
*/ |
61
|
38 |
|
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
62
|
|
|
{ |
63
|
38 |
|
return 'TIME(0)'; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritDoc} |
68
|
|
|
*/ |
69
|
47 |
|
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
70
|
|
|
{ |
71
|
47 |
|
return 'DATETIMEOFFSET(6)'; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritDoc} |
76
|
|
|
*/ |
77
|
22 |
|
public function getDateTimeFormatString() |
78
|
|
|
{ |
79
|
22 |
|
return 'Y-m-d H:i:s.u'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritDoc} |
84
|
|
|
*/ |
85
|
2 |
|
public function getDateTimeTzFormatString() |
86
|
|
|
{ |
87
|
2 |
|
return 'Y-m-d H:i:s.u P'; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritDoc} |
92
|
|
|
*/ |
93
|
2 |
|
public function getDateFormatString() |
94
|
|
|
{ |
95
|
2 |
|
return 'Y-m-d'; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* {@inheritDoc} |
100
|
|
|
*/ |
101
|
2 |
|
public function getTimeFormatString() |
102
|
|
|
{ |
103
|
2 |
|
return 'H:i:s'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritDoc} |
108
|
|
|
* |
109
|
|
|
* Adding Datetime2 Type |
110
|
|
|
*/ |
111
|
172 |
|
protected function initializeDoctrineTypeMappings() |
112
|
|
|
{ |
113
|
172 |
|
parent::initializeDoctrineTypeMappings(); |
114
|
172 |
|
$this->doctrineTypeMapping['datetime2'] = 'datetime'; |
115
|
172 |
|
$this->doctrineTypeMapping['date'] = 'date'; |
116
|
172 |
|
$this->doctrineTypeMapping['time'] = 'time'; |
117
|
172 |
|
$this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz'; |
118
|
172 |
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
* |
123
|
|
|
* Returns Microsoft SQL Server 2008 specific keywords class |
124
|
|
|
*/ |
125
|
1054 |
|
protected function getReservedKeywordsClass() |
126
|
|
|
{ |
127
|
1054 |
|
return Keywords\SQLServer2008Keywords::class; |
128
|
|
|
} |
129
|
|
|
|
130
|
36 |
|
protected function getLikeWildcardCharacters() : string |
131
|
|
|
{ |
132
|
36 |
|
return parent::getLikeWildcardCharacters() . '[]^'; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|