Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
9f72045a
Commit
9f72045a
authored
Sep 05, 2015
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#869 - DBAL-1293 - simplified conversion logic for readability
parent
bd142a58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
13 deletions
+22
-13
DateTimeType.php
lib/Doctrine/DBAL/Types/DateTimeType.php
+7
-4
DateTimeTzType.php
lib/Doctrine/DBAL/Types/DateTimeTzType.php
+8
-5
DateType.php
lib/Doctrine/DBAL/Types/DateType.php
+7
-4
No files found.
lib/Doctrine/DBAL/Types/DateTimeType.php
View file @
9f72045a
...
@@ -49,12 +49,15 @@ class DateTimeType extends Type
...
@@ -49,12 +49,15 @@ class DateTimeType extends Type
*/
*/
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
!==
null
&&
!
$value
instanceof
\DateTime
)
{
if
(
null
===
$value
)
{
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
"DateTime"
);
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
return
$value
->
format
(
$platform
->
getDateTimeFormatString
());
}
}
return
(
$value
!==
null
)
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
'DateTime'
);
?
$value
->
format
(
$platform
->
getDateTimeFormatString
())
:
null
;
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Types/DateTimeTzType.php
View file @
9f72045a
...
@@ -67,12 +67,15 @@ class DateTimeTzType extends Type
...
@@ -67,12 +67,15 @@ class DateTimeTzType extends Type
*/
*/
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
!==
null
&&
!
$value
instanceof
\DateTime
)
{
if
(
null
===
$value
)
{
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
"DateTime"
);
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
return
$value
->
format
(
$platform
->
getDateTimeTzFormatString
());
}
}
return
(
$value
!==
null
)
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
'DateTime'
);
?
$value
->
format
(
$platform
->
getDateTimeTzFormatString
())
:
null
;
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Types/DateType.php
View file @
9f72045a
...
@@ -49,12 +49,15 @@ class DateType extends Type
...
@@ -49,12 +49,15 @@ class DateType extends Type
*/
*/
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToDatabaseValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
!==
null
&&
!
$value
instanceof
\DateTime
)
{
if
(
null
===
$value
)
{
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
"DateTime"
);
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
return
$value
->
format
(
$platform
->
getDateFormatString
());
}
}
return
(
$value
!==
null
)
throw
ConversionException
::
conversionFailedInvalidType
(
$value
,
$this
->
getName
(),
'DateTime'
);
?
$value
->
format
(
$platform
->
getDateFormatString
())
:
null
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment