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
104f97e6
Commit
104f97e6
authored
Feb 05, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-216] Add support for Date types to also handle already instantiated DateTime instances.
parent
a62df738
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
50 additions
and
20 deletions
+50
-20
DateTimeType.php
lib/Doctrine/DBAL/Types/DateTimeType.php
+3
-3
DateTimeTzType.php
lib/Doctrine/DBAL/Types/DateTimeTzType.php
+3
-3
DateType.php
lib/Doctrine/DBAL/Types/DateType.php
+3
-3
TimeType.php
lib/Doctrine/DBAL/Types/TimeType.php
+3
-3
VarDateTimeType.php
lib/Doctrine/DBAL/Types/VarDateTimeType.php
+3
-3
DateTest.php
tests/Doctrine/Tests/DBAL/Types/DateTest.php
+7
-1
DateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
+7
-1
DateTimeTzTest.php
tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
+7
-1
TimeTest.php
tests/Doctrine/Tests/DBAL/Types/TimeTest.php
+7
-1
VarDateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
+7
-1
No files found.
lib/Doctrine/DBAL/Types/DateTimeType.php
View file @
104f97e6
...
@@ -46,8 +46,8 @@ class DateTimeType extends Type
...
@@ -46,8 +46,8 @@ class DateTimeType extends Type
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
return
null
;
return
$value
;
}
}
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
...
...
lib/Doctrine/DBAL/Types/DateTimeTzType.php
View file @
104f97e6
...
@@ -66,8 +66,8 @@ class DateTimeTzType extends Type
...
@@ -66,8 +66,8 @@ class DateTimeTzType extends Type
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
return
null
;
return
$value
;
}
}
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getDateTimeTzFormatString
(),
$value
);
...
...
lib/Doctrine/DBAL/Types/DateType.php
View file @
104f97e6
...
@@ -46,8 +46,8 @@ class DateType extends Type
...
@@ -46,8 +46,8 @@ class DateType extends Type
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
return
null
;
return
$value
;
}
}
$val
=
\DateTime
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
$val
=
\DateTime
::
createFromFormat
(
'!'
.
$platform
->
getDateFormatString
(),
$value
);
...
...
lib/Doctrine/DBAL/Types/TimeType.php
View file @
104f97e6
...
@@ -55,8 +55,8 @@ class TimeType extends Type
...
@@ -55,8 +55,8 @@ class TimeType extends Type
*/
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
return
null
;
return
$value
;
}
}
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getTimeFormatString
(),
$value
);
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getTimeFormatString
(),
$value
);
...
...
lib/Doctrine/DBAL/Types/VarDateTimeType.php
View file @
104f97e6
...
@@ -47,8 +47,8 @@ class VarDateTimeType extends DateTimeType
...
@@ -47,8 +47,8 @@ class VarDateTimeType extends DateTimeType
*/
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
{
if
(
$value
===
null
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
return
null
;
return
$value
;
}
}
$val
=
date_create
(
$value
);
$val
=
date_create
(
$value
);
...
...
tests/Doctrine/Tests/DBAL/Types/DateTest.php
View file @
104f97e6
...
@@ -72,4 +72,10 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
...
@@ -72,4 +72,10 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
}
}
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
View file @
104f97e6
...
@@ -47,4 +47,10 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -47,4 +47,10 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
}
}
tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
View file @
104f97e6
...
@@ -47,4 +47,10 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
...
@@ -47,4 +47,10 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
}
}
tests/Doctrine/Tests/DBAL/Types/TimeTest.php
View file @
104f97e6
...
@@ -44,4 +44,10 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -44,4 +44,10 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
}
}
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
View file @
104f97e6
...
@@ -59,4 +59,10 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -59,4 +59,10 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testConvertDateTimeToPHPValue
()
{
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
}
}
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