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 LGPL. 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 SQLServer2008 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 | * @override |
---|
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 | * @override |
---|
42 | */ |
---|
43 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
---|
44 | { |
---|
45 | return 'DATE'; |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * @override |
---|
50 | */ |
---|
51 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
---|
52 | { |
---|
53 | return 'TIME(0)'; |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * @override |
---|
58 | */ |
---|
59 | public function getDateTimeFormatString() |
---|
60 | { |
---|
61 | return 'Y-m-d H:i:s.u'; |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * @override |
---|
66 | */ |
---|
67 | public function getDateFormatString() |
---|
68 | { |
---|
69 | return 'Y-m-d'; |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * @override |
---|
74 | */ |
---|
75 | public function getTimeFormatString() |
---|
76 | { |
---|
77 | return 'H:i:s'; |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | * Adding Datetime2 Type |
---|
82 | */ |
---|
83 | protected function initializeDoctrineTypeMappings() |
---|
84 | { |
---|
85 | parent::initializeDoctrineTypeMappings(); |
---|
86 | $this->doctrineTypeMapping['datetime2'] = 'datetime'; |
---|
87 | $this->doctrineTypeMapping['date'] = 'date'; |
---|
88 | $this->doctrineTypeMapping['time'] = 'time'; |
---|
89 | } |
---|
90 | } |
---|