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
|
|
|
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
34
|
|
|
{ |
35
|
|
|
// 3 - microseconds precision length |
36
|
|
|
// http://msdn.microsoft.com/en-us/library/ms187819.aspx |
37
|
|
|
return 'DATETIME2(6)'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
*/ |
43
|
|
|
public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
44
|
|
|
{ |
45
|
|
|
return 'DATE'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritDoc} |
50
|
|
|
*/ |
51
|
|
|
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
52
|
|
|
{ |
53
|
|
|
return 'TIME(0)'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritDoc} |
58
|
|
|
*/ |
59
|
1 |
|
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
60
|
|
|
{ |
61
|
1 |
|
return 'DATETIMEOFFSET(6)'; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritDoc} |
66
|
|
|
*/ |
67
|
|
|
public function getDateTimeFormatString() |
68
|
|
|
{ |
69
|
|
|
return 'Y-m-d H:i:s.u'; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritDoc} |
74
|
|
|
*/ |
75
|
|
|
public function getDateTimeTzFormatString() |
76
|
|
|
{ |
77
|
|
|
return 'Y-m-d H:i:s.u P'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritDoc} |
82
|
|
|
*/ |
83
|
|
|
public function getDateFormatString() |
84
|
|
|
{ |
85
|
|
|
return 'Y-m-d'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritDoc} |
90
|
|
|
*/ |
91
|
|
|
public function getTimeFormatString() |
92
|
|
|
{ |
93
|
|
|
return 'H:i:s'; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* {@inheritDoc} |
98
|
|
|
* |
99
|
|
|
* Adding Datetime2 Type |
100
|
|
|
*/ |
101
|
10 |
|
protected function initializeDoctrineTypeMappings() |
102
|
|
|
{ |
103
|
10 |
|
parent::initializeDoctrineTypeMappings(); |
104
|
10 |
|
$this->doctrineTypeMapping['datetime2'] = 'datetime'; |
105
|
10 |
|
$this->doctrineTypeMapping['date'] = 'date'; |
106
|
10 |
|
$this->doctrineTypeMapping['time'] = 'time'; |
107
|
10 |
|
$this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz'; |
108
|
10 |
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
* |
113
|
|
|
* Returns Microsoft SQL Server 2008 specific keywords class |
114
|
|
|
*/ |
115
|
57 |
|
protected function getReservedKeywordsClass() |
116
|
|
|
{ |
117
|
57 |
|
return Keywords\SQLServer2008Keywords::class; |
118
|
|
|
} |
119
|
|
|
|
120
|
2 |
|
protected function getLikeWildcardCharacters() : string |
121
|
|
|
{ |
122
|
2 |
|
return parent::getLikeWildcardCharacters() . '[]^'; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|