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
9b5f3080
Commit
9b5f3080
authored
Aug 06, 2013
by
amakhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hour to DATE_ADD and DATE_SUB
parent
2a7f59c1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
0 deletions
+126
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+30
-0
DrizzlePlatform.php
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
+16
-0
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+16
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+16
-0
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+16
-0
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+16
-0
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+16
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
9b5f3080
...
...
@@ -939,6 +939,36 @@ abstract class AbstractPlatform
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* Returns the SQL to add the number of given hours to a date.
*
* @param string $date
* @param integer $hours
*
* @return string
*
* @throws \Doctrine\DBAL\DBALException If not supported on this platform.
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* Returns the SQL to subtract the number of given hours to a date.
*
* @param string $date
* @param integer $hours
*
* @return string
*
* @throws \Doctrine\DBAL\DBALException If not supported on this platform.
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* Returns the SQL to add the number of given days to a date.
*
...
...
lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
View file @
9b5f3080
...
...
@@ -65,6 +65,22 @@ class DrizzlePlatform extends AbstractPlatform
return
'DATEDIFF('
.
$date1
.
', '
.
$date2
.
')'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
'DATE_ADD('
.
$date
.
', INTERVAL '
.
$hours
.
' HOUR)'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
'DATE_SUB('
.
$date
.
', INTERVAL '
.
$hours
.
' HOUR)'
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
9b5f3080
...
...
@@ -115,6 +115,22 @@ class MySqlPlatform extends AbstractPlatform
return
'DATEDIFF('
.
$date1
.
', '
.
$date2
.
')'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
'DATE_ADD('
.
$date
.
', INTERVAL '
.
$hours
.
' HOUR)'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
'DATE_SUB('
.
$date
.
', INTERVAL '
.
$hours
.
' HOUR)'
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
9b5f3080
...
...
@@ -110,6 +110,22 @@ class OraclePlatform extends AbstractPlatform
return
"TRUNC(TO_NUMBER(SUBSTR(("
.
$date1
.
"-"
.
$date2
.
"), 1, INSTR("
.
$date1
.
"-"
.
$date2
.
", ' '))))"
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
'('
.
$date
.
'+'
.
$hours
.
'/24)'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
'('
.
$date
.
'-'
.
$hours
.
'/24)'
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
9b5f3080
...
...
@@ -100,6 +100,22 @@ class PostgreSqlPlatform extends AbstractPlatform
return
'(DATE('
.
$date1
.
')-DATE('
.
$date2
.
'))'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
"("
.
$date
.
" + ("
.
$hours
.
" || ' hour')::interval)"
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
"("
.
$date
.
" - ("
.
$hours
.
" || ' hour')::interval)"
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
9b5f3080
...
...
@@ -46,6 +46,22 @@ class SQLServerPlatform extends AbstractPlatform
return
'DATEDIFF(day, '
.
$date2
.
','
.
$date1
.
')'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
'DATEADD(hour, '
.
$hours
.
', '
.
$date
.
')'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
'DATEADD(hour, -1 * '
.
$hours
.
', '
.
$date
.
')'
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
9b5f3080
...
...
@@ -130,6 +130,22 @@ class SqlitePlatform extends AbstractPlatform
return
'ROUND(JULIANDAY('
.
$date1
.
')-JULIANDAY('
.
$date2
.
'))'
;
}
/**
* {@inheritDoc}
*/
public
function
getDateAddHourExpression
(
$date
,
$hours
)
{
return
"DATE("
.
$date
.
",'+"
.
$hours
.
" hour')"
;
}
/**
* {@inheritDoc}
*/
public
function
getDateSubHourExpression
(
$date
,
$hours
)
{
return
"DATE("
.
$date
.
",'-"
.
$hours
.
" hour')"
;
}
/**
* {@inheritDoc}
*/
...
...
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