本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例9: convertToDatabaseValue
public function convertToDatabaseValue($timepoint, AbstractPlatform $platform)
{
if ($timepoint !== null) {
$dtime = $timepoint->asPHPDateTime();
return $dtime->format($platform->getDateTimeFormatString());
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}