MediaWiki  master
TimestampType.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
5 use Doctrine\DBAL\Platforms\AbstractPlatform;
6 use Doctrine\DBAL\Types\Type;
7 
12 class 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 }
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\TimestampType
Handling timestamp edge cases in mediawiki.
Definition: TimestampType.php:12
Wikimedia\Rdbms\TimestampType\TIMESTAMP
const TIMESTAMP
Definition: TimestampType.php:13
Wikimedia\Rdbms\TimestampType\getSQLDeclaration
getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
Definition: TimestampType.php:15
Wikimedia\Rdbms\TimestampType\getName
getName()
Definition: TimestampType.php:35