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
|
|
|
* @deprecated Use SQL Server 2012 or newer |
12
|
|
|
*/ |
13
|
|
|
class SQLServer2008Platform extends SQLServer2005Platform |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
|
|
*/ |
18
|
484 |
|
public function getListTablesSQL() |
19
|
|
|
{ |
20
|
|
|
// "sysdiagrams" table must be ignored as it's internal SQL Server table for Database Diagrams |
21
|
|
|
// Category 2 must be ignored as it is "MS SQL Server 'pseudo-system' object[s]" for replication |
22
|
484 |
|
return "SELECT name, SCHEMA_NAME (uid) AS schema_name FROM sysobjects WHERE type = 'U' AND name != 'sysdiagrams' AND category != 2 ORDER BY name"; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritDoc} |
27
|
|
|
*/ |
28
|
511 |
|
public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
29
|
|
|
{ |
30
|
|
|
// 3 - microseconds precision length |
31
|
|
|
// http://msdn.microsoft.com/en-us/library/ms187819.aspx |
32
|
511 |
|
return 'DATETIME2(6)'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritDoc} |
37
|
|
|
*/ |
38
|
457 |
|
public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
39
|
|
|
{ |
40
|
457 |
|
return 'DATE'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritDoc} |
45
|
|
|
*/ |
46
|
454 |
|
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
47
|
|
|
{ |
48
|
454 |
|
return 'TIME(0)'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritDoc} |
53
|
|
|
*/ |
54
|
1882 |
|
public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) |
55
|
|
|
{ |
56
|
1882 |
|
return 'DATETIMEOFFSET(6)'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritDoc} |
61
|
|
|
*/ |
62
|
508 |
|
public function getDateTimeFormatString() |
63
|
|
|
{ |
64
|
508 |
|
return 'Y-m-d H:i:s.u'; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritDoc} |
69
|
|
|
*/ |
70
|
239 |
|
public function getDateTimeTzFormatString() |
71
|
|
|
{ |
72
|
239 |
|
return 'Y-m-d H:i:s.u P'; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritDoc} |
77
|
|
|
*/ |
78
|
236 |
|
public function getDateFormatString() |
79
|
|
|
{ |
80
|
236 |
|
return 'Y-m-d'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritDoc} |
85
|
|
|
*/ |
86
|
156 |
|
public function getTimeFormatString() |
87
|
|
|
{ |
88
|
156 |
|
return 'H:i:s'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* {@inheritDoc} |
93
|
|
|
* |
94
|
|
|
* Adding Datetime2 Type |
95
|
|
|
*/ |
96
|
1822 |
|
protected function initializeDoctrineTypeMappings() |
97
|
|
|
{ |
98
|
1822 |
|
parent::initializeDoctrineTypeMappings(); |
99
|
1822 |
|
$this->doctrineTypeMapping['datetime2'] = 'datetime'; |
100
|
1822 |
|
$this->doctrineTypeMapping['date'] = 'date'; |
101
|
1822 |
|
$this->doctrineTypeMapping['time'] = 'time'; |
102
|
1822 |
|
$this->doctrineTypeMapping['datetimeoffset'] = 'datetimetz'; |
103
|
1822 |
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* {@inheritdoc} |
107
|
|
|
* |
108
|
|
|
* Returns Microsoft SQL Server 2008 specific keywords class |
109
|
|
|
*/ |
110
|
1912 |
|
protected function getReservedKeywordsClass() |
111
|
|
|
{ |
112
|
1912 |
|
return Keywords\SQLServer2008Keywords::class; |
113
|
|
|
} |
114
|
|
|
|
115
|
643 |
|
protected function getLikeWildcardCharacters() : string |
116
|
|
|
{ |
117
|
643 |
|
return parent::getLikeWildcardCharacters() . '[]^'; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|