| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\Rdbms; |
| 4 |
|
| 5 |
use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 6 |
use Doctrine\DBAL\Types\Type; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 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 |
|
| 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 |
} |