Classes

File io/db/dbms/Doctrine/DBAL/Types/DateTimeType.php

File io/db/dbms/Doctrine/DBAL/Types/DateTimeType.php

 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 
<?php
/**
 * Type that maps an SQL DATETIME/TIMESTAMP to a PHP DateTime object.
 * @package     Doctrine
 * @subpackage  DBAL\Types
 * @license     https://www.gnu.org/licenses/lgpl-2.1.fr.html LGPL 2.1
 * @link        https://www.doctrine-project.org
 * @version     PHPBoost 5.2 - last update: 2013 01 01
 * @since       PHPBoost 4.0 - 2013 01 01
*/

class DateTimeType extends Type
{
    public function getName()
    {
        return 'DateTime';
    }

    public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        return $platform->getDateTimeTypeDeclarationSql($fieldDeclaration);
    }

    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return ($value !== null)
            ? $value->format($platform->getDateTimeFormatString()) : null;
    }

    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        return ($value !== null)
            ? DateTime::createFromFormat($platform->getDateTimeFormatString(), $value) : null;
    }
}

?>