Exemplo n.º 1
0
 /**
  * Converts a DateAndTime object to a proper datetime/timestamp/time representation 
  * for this Database.
  *
  * @access public
  * @param ref object dateAndTime The DateAndTime object to convert.
  * @return mixed A proper datetime/timestamp/time representation for this Database.
  */
 function toDBDate(DateAndTime $dateAndTime)
 {
     $dt = $dateAndTime->asDateAndTime();
     $string = sprintf("%s/%02d/%02d %02d:%02d:%02d", $dt->year(), $dt->month(), $dt->dayOfMonth(), $dt->hour24(), $dt->minute(), $dt->second());
     return "to_date('{$string}', 'yyyy/mm/dd hh24:mi:ss')";
 }
Exemplo n.º 2
0
 /**
  * Converts a DateAndTime object to a proper datetime/timestamp/time representation 
  * for this Database.
  *
  * The easiest way to convert is to create an integer (or a string,
  * choose which one you think is better, MySQL accepts both, but make
  * sure to document) in the following format: YYYYMMDDHHMMSS.
  * You can pass this to a MySQL datetime or timestamp column types
  * and it gets parsed automatically by MySQL.
  *
  * @access public
  * @param ref object DateAndTime The DateAndTime object to convert.
  * @return mixed A proper datetime/timestamp/time representation for this Database.
  */
 function toDBDate(DateAndTime $dateAndTime)
 {
     $dt = $dateAndTime->asDateAndTime();
     $string = sprintf("%s%02d%02d%02d%02d%02d", $dt->year(), $dt->month(), $dt->dayOfMonth(), $dt->hour24(), $dt->minute(), $dt->second());
     return "'" . $string . "'";
 }