|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\DBAL\Platforms; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Platform to ensure compatibility of Doctrine with Microsoft SQL Server 2008 version. |
|
7
|
|
|
* |
|
8
|
|
|
* Differences to SQL Server 2005 and before are that a new DATETIME2 type was |
|
9
|
|
|
* introduced that has a higher precision. |
|
10
|
|
|
*/ |
|
11
|
|
|
class SQLServer2008Platform extends SQLServer2005Platform |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritDoc} |
|
15
|
|
|
*/ |
|
16
|
321 |
|
public function getListTablesSQL() |
|
17
|
|
|
{ |
|
18
|
|
|
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams |
|
19
|
|
|
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication |
|
20
|
321 |
|
return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name"; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritDoc} |
|
25
|
|
|
*/ |
|
26
|
339 |
|
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
|
27
|
|
|
{ |
|
28
|
|
|
// 3 - microseconds precision length |
|
29
|
|
|
// http://msdn.microsoft.com/en-us/library/ms187819.aspx |
|
30
|
339 |
|
return 'DATETIME2(6)'; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
303 |
|
public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
|
37
|
|
|
{ |
|
38
|
303 |
|
return 'DATE'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritDoc} |
|
43
|
|
|
*/ |
|
44
|
301 |
|
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
|
45
|
|
|
{ |
|
46
|
301 |
|
return 'TIME(0)'; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritDoc} |
|
51
|
|
|
*/ |
|
52
|
1862 |
|
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
|
53
|
|
|
{ |
|
54
|
1862 |
|
return 'DATETIMEOFFSET(6)'; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritDoc} |
|
59
|
|
|
*/ |
|
60
|
337 |
|
public function getDateTimeFormatString() |
|
61
|
|
|
{ |
|
62
|
337 |
|
return 'Y-m-d H:i:s.u'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritDoc} |
|
67
|
|
|
*/ |
|
68
|
158 |
|
public function getDateTimeTzFormatString() |
|
69
|
|
|
{ |
|
70
|
158 |
|
return 'Y-m-d H:i:s.u P'; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritDoc} |
|
75
|
|
|
*/ |
|
76
|
156 |
|
public function getDateFormatString() |
|
77
|
|
|
{ |
|
78
|
156 |
|
return 'Y-m-d'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritDoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getTimeFormatString() |
|
85
|
|
|
{ |
|
86
|
|
|
return 'H:i:s'; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritDoc} |
|
91
|
|
|
* |
|
92
|
|
|
* Adding Datetime2 Type |
|
93
|
|
|
*/ |
|
94
|
1743 |
|
protected function initializeDoctrineTypeMappings() |
|
95
|
|
|
{ |
|
96
|
1743 |
|
parent::initializeDoctrineTypeMappings(); |
|
97
|
1743 |
|
$this->doctrineTypeMapping['datetime2'] = 'datetime'; |
|
98
|
1743 |
|
$this->doctrineTypeMapping['date'] = 'date'; |
|
99
|
1743 |
|
$this->doctrineTypeMapping['time'] = 'time'; |
|
100
|
1743 |
|
$this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz'; |
|
101
|
1743 |
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* {@inheritdoc} |
|
105
|
|
|
* |
|
106
|
|
|
* Returns Microsoft SQL Server 2008 specific keywords class |
|
107
|
|
|
*/ |
|
108
|
1974 |
|
protected function getReservedKeywordsClass() |
|
109
|
|
|
{ |
|
110
|
1974 |
|
return Keywords\SQLServer2008Keywords::class; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
488 |
|
protected function getLikeWildcardCharacters() : string |
|
114
|
|
|
{ |
|
115
|
488 |
|
return parent::getLikeWildcardCharacters() . '[]^'; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|