當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。