mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 23:29:31 +01:00
new method to abstract MySQL function unix_timestamp (convert db timestamp to integer)
This commit is contained in:
parent
b034fa0139
commit
e3f9da7613
@ -1232,6 +1232,28 @@ class egw_db
|
||||
return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a DB specific timestamp in a unix timestamp stored as integer, like MySQL: UNIX_TIMESTAMP(ts)
|
||||
*
|
||||
* @param string $expr name of an integer column or integer expression
|
||||
* @return string SQL expression of type timestamp
|
||||
*/
|
||||
function unix_timestamp($expr)
|
||||
{
|
||||
switch($this->Type)
|
||||
{
|
||||
case 'mysql':
|
||||
return "UNIX_TIMESTAMP($expr)";
|
||||
|
||||
case 'pgsql':
|
||||
return "DATE_PART('epoch',$expr)";
|
||||
|
||||
case 'mssql':
|
||||
return "DATEDIFF(second,'1970-01-01',($expr))";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a unix timestamp stored as integer in the db into a db timestamp, like MySQL: FROM_UNIXTIME(ts)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user