mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-03 12:00:09 +01:00
new method to abstract MySQL function unix_timestamp (convert db timestamp to integer)
This commit is contained in:
parent
f5f47c4ad1
commit
83dae424e0
@ -1232,6 +1232,28 @@ class egw_db
|
|||||||
return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
|
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)
|
* 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