====== dbDate ======
~~NOTOC~~
== syntax ==
string dbDate(){
float $timestamp
}
===== Description =====
The function ''dbDate()'' accepts a Unix Timestamp value, and returns a database-specific date string. This can then be used in SQL statements. The returned value differs from one database to another.
Note that the returned value already includes any required quoting
===== Usage =====
==== MySQL example ====
/*
* Connection to MySQL database assumed
*/
$date = date('Y-m-d');
$d = $db->dbDate($date);
/*
* Returns the following string: '2015-07-19'
*/
$SQL = "SELECT * FROM record WHERE date_field=$d";
==== Oracle Example ====
/*
* Connection to Oracle database assumed
*/
$date = date('Y-m-d');
$d = $db->dbDate($date);
/*
* Returns the following string: TO_DATE('2015-07-19','YYYY-MM-DD')
*/
$SQL = "SELECT * FROM record WHERE date_field=$d";