当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractPlatform::getDateTimeFormatString方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getDateTimeFormatString方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::getDateTimeFormatString方法的具体用法?PHP AbstractPlatform::getDateTimeFormatString怎么用?PHP AbstractPlatform::getDateTimeFormatString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Platforms\AbstractPlatform的用法示例。


在下文中一共展示了AbstractPlatform::getDateTimeFormatString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convertToDatabaseValue

 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     if ($value instanceof Carbon) {
         return $value->copy()->setTimezone('UTC')->format($platform->getDateTimeFormatString());
     }
     throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
 }
开发者ID:Zn4rK,项目名称:laravel-template,代码行数:13,代码来源:CarbonType.php

示例2: convertToPHPValue

 /**
  * @param string $dateTimeString
  * @param AbstractPlatform $platform
  *
  * @throws ConversionException
  *
  * @return DateTime|null
  */
 public function convertToPHPValue($dateTimeString, AbstractPlatform $platform)
 {
     if (null === $dateTimeString || $dateTimeString instanceof DateTime) {
         return $dateTimeString;
     }
     $dateTime = DateTime::createFromFormat($platform->getDateTimeFormatString(), $dateTimeString, self::getUtc());
     if (!$dateTime) {
         throw ConversionException::conversionFailedFormat($dateTimeString, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $dateTime;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:19,代码来源:UTCDateTimeType.php

示例3: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof Date) {
         return $value;
     }
     $val = Date::createFromFormat($platform->getDateTimeFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $val;
 }
开发者ID:hmlb,项目名称:date-bundle,代码行数:14,代码来源:DateTimeType.php

示例4: convertToPHPValue

 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     $val = \Psc\DateTime\DateTime::parse($platform->getDateTimeFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $val;
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:11,代码来源:DateTimeType.php

示例5: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if (null === $value || $value instanceof \DateTime) {
         return $value;
     }
     $converted = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value, self::$utc ? self::$utc : (self::$utc = new \DateTimeZone('UTC')));
     if (!$converted) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $converted;
 }
开发者ID:tarlepp,项目名称:silex-backend,代码行数:14,代码来源:UTCDateTimeType.php

示例6: convertToPHPValue

 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === NULL) {
         return NULL;
     } elseif ($value instanceof \DateTime) {
         return NetteDateTime::from($value);
     }
     $val = NetteDateTime::createFromFormat($platform->getDateTimeFormatString(), $value);
     if (!$val) {
         throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return NetteDateTime::from($val);
 }
开发者ID:ATouhou,项目名称:db-benchmark,代码行数:13,代码来源:DateTimeType.php

示例7: convertToPHPValue

 /**
  * @param \DateTimeImmutable|string|null $value
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
  * @return \DateTimeImmutable|null
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof DateTimeImmutable) {
         return $value;
     }
     $dateTime = DateTimeImmutable::createFromFormat($platform->getDateTimeFormatString(), $value);
     if ($dateTime === false) {
         $dateTime = date_create_immutable($value);
     }
     if ($dateTime === false) {
         throw \Doctrine\DBAL\Types\ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $dateTime;
 }
开发者ID:researchsquare,项目名称:Doctrine-Date-Time-Immutable-Types,代码行数:19,代码来源:DateTimeImmutableType.php

示例8: convertToPHPValue

 /**
  * @param \DateTimeImmutable|string|null $value
  * @param AbstractPlatform               $platform
  * @return \DateTimeImmutable|null
  * @throws ConversionException
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null || $value instanceof \DateTimeImmutable) {
         return $value;
     }
     if (is_string($value)) {
         $dateTime = \DateTimeImmutable::createFromFormat($platform->getDateTimeFormatString(), $value);
         if ($dateTime !== false) {
             return $dateTime;
         }
     }
     if (is_array($value) || is_object($value)) {
         $value = print_r($value, true);
     }
     throw ConversionException::conversionFailedFormat((string) $value, $this->getName(), $platform->getDateTimeFormatString());
 }
开发者ID:index0h,项目名称:dbal-types,代码行数:22,代码来源:DateTimeImmutableType.php

示例9: convertToDatabaseValue

 public function convertToDatabaseValue($timepoint, AbstractPlatform $platform)
 {
     if ($timepoint !== null) {
         $dtime = $timepoint->asPHPDateTime();
         return $dtime->format($platform->getDateTimeFormatString());
     }
 }
开发者ID:rouffj,项目名称:timemachine,代码行数:7,代码来源:TimePointType.php

示例10: findRevisions

 /**
  * Find all revisions that were made of entity class with given id.
  *
  * @param string $className
  * @param mixed $id
  * @throws NotAuditedException
  * @return Revision[]
  */
 public function findRevisions($className, $id)
 {
     if (!$this->metadataFactory->isAudited($className)) {
         throw new NotAuditedException($className);
     }
     /** @var ClassMetadataInfo|ClassMetadata $class */
     $class = $this->em->getClassMetadata($className);
     $tableName = $this->config->getTableName($class);
     if (!is_array($id)) {
         $id = array($class->identifier[0] => $id);
     }
     $whereSQL = "";
     foreach ($class->identifier as $idField) {
         if (isset($class->fieldMappings[$idField])) {
             if ($whereSQL) {
                 $whereSQL .= " AND ";
             }
             $whereSQL .= "e." . $class->fieldMappings[$idField]['columnName'] . " = ?";
         } else {
             if (isset($class->associationMappings[$idField])) {
                 if ($whereSQL) {
                     $whereSQL .= " AND ";
                 }
                 $whereSQL .= "e." . $class->associationMappings[$idField]['joinColumns'][0] . " = ?";
             }
         }
     }
     $query = "SELECT r.* FROM " . $this->config->getRevisionTableName() . " r " . "INNER JOIN " . $tableName . " e ON r.id = e." . $this->config->getRevisionFieldName() . " WHERE " . $whereSQL . " ORDER BY r.id DESC";
     $revisionsData = $this->em->getConnection()->fetchAll($query, array_values($id));
     $revisions = array();
     foreach ($revisionsData as $row) {
         $revisions[] = new Revision($row['id'], \DateTime::createFromFormat($this->platform->getDateTimeFormatString(), $row['timestamp']), $row['username']);
     }
     return $revisions;
 }
开发者ID:Soullivaneuh,项目名称:EntityAudit,代码行数:43,代码来源:AuditReader.php

示例11: convertToDatabaseValue

 /**
  * @param DateTimeOfDay $value
  * @param AbstractPlatform $platform
  *
  * @return string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value instanceof DateTimeOfDay) {
         return $value->toDateTime()->format($platform->getDateTimeFormatString());
     }
     return parent::convertToDatabaseValue($value, $platform);
 }
开发者ID:zelenin,项目名称:value-object,代码行数:13,代码来源:DateTimeOfDayType.php

示例12: getConvertedParams

 /**
  * Get the converted parameter list
  *
  * @param array $params
  * @param array $types
  * @return array
  */
 private function getConvertedParams($params, $types)
 {
     $result = array();
     foreach ($params as $position => $value) {
         if (isset($types[$position])) {
             $type = $types[$position];
             if (is_string($type)) {
                 $type = Type::getType($type);
             }
             if ($type instanceof Type) {
                 $value = $type->convertToDatabaseValue($value, $this->platform);
             }
         } else {
             if (is_object($value) && $value instanceof \DateTime) {
                 $value = $value->format($this->platform->getDateTimeFormatString());
             } elseif (!is_null($value)) {
                 $type = Type::getType(gettype($value));
                 $value = $type->convertToDatabaseValue($value, $this->platform);
             }
         }
         if (is_string($value)) {
             $value = "'{$value}'";
         } elseif (is_null($value)) {
             $value = 'NULL';
         }
         $result[$position] = $value;
     }
     return $result;
 }
开发者ID:justus-alex,项目名称:TaxiPrize,代码行数:36,代码来源:QueryAnalyzer.php

示例13: convertToPHPValue

 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($databaseValue, AbstractPlatform $platform)
 {
     if (null === $databaseValue || $databaseValue instanceof \DateTime) {
         return $databaseValue;
     }
     // The changed part is the following bloc where we put the DateTimeZone as the third argument rather than
     // relying on the local timezone
     $phpValue = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $databaseValue, new \DateTimeZone('UTC'));
     if (false === $phpValue) {
         $phpValue = date_create($databaseValue);
     }
     if (false === $phpValue) {
         throw ConversionException::conversionFailedFormat($databaseValue, $this->getName(), $platform->getDateTimeFormatString());
     }
     return $phpValue;
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:19,代码来源:UTCDateTimeType.php

示例14: convertToPHPValue

 /** @noinspection PhpMissingParentCallCommonInspection
  * @inheritdoc
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     /** @var string|null $value */
     if ($value === null) {
         return null;
     }
     return $this->convertDateTimeString($value, $platform->getDateTimeFormatString(), static::JSON_API_FORMAT);
 }
开发者ID:limoncello-php,项目名称:json-api,代码行数:11,代码来源:DateTimeDefaultStringType.php

示例15: convertToDatabaseValue

 /** @noinspection PhpMissingParentCallCommonInspection
  * @inheritdoc
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     /** @var DateTime|null $value */
     if ($value === null) {
         return null;
     }
     return $value->format($platform->getDateTimeFormatString());
 }
开发者ID:limoncello-php,项目名称:json-api,代码行数:11,代码来源:DateTimeJsonApiNativeType.php


注:本文中的Doctrine\DBAL\Platforms\AbstractPlatform::getDateTimeFormatString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。