MediaWiki master
TimestampType.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use Doctrine\DBAL\Platforms\AbstractPlatform;
6use Doctrine\DBAL\Types\Type;
7
12class TimestampType extends Type {
13 public const TIMESTAMP = 'mwtimestamp';
14
15 public function getSQLDeclaration( array $fieldDeclaration, AbstractPlatform $platform ) {
16 if ( $platform->getName() == 'mysql' ) {
17 // "infinite" (in expiry values has to be VARBINARY)
18 if ( isset( $fieldDeclaration['allowInfinite'] ) && $fieldDeclaration['allowInfinite'] ) {
19 return 'VARBINARY(14)';
20 }
21 return 'BINARY(14)';
22 }
23
24 if ( $platform->getName() == 'sqlite' ) {
25 return 'BLOB';
26 }
27
28 if ( $platform->getName() == 'postgresql' ) {
29 return 'TIMESTAMPTZ';
30 }
31
32 return $platform->getDateTimeTzTypeDeclarationSQL( $fieldDeclaration );
33 }
34
35 public function getName() {
36 return self::TIMESTAMP;
37 }
38}
Handling timestamp edge cases in mediawiki.
getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)