Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
N/A
-
Resolution: Won't Fix
-
Affects Version/s: 1.0.0, 1.0.1, 1.0.2
-
Fix Version/s: None
-
Component/s: Zend_Db
-
Labels:
Description
*Followup to the ML discussion located HERE*
- All Zend_Db_Adapters should get new private properties named $_dateFormat, $_timeFormat and $_datetimeFormat. These properties should contain Zend_Date formatstrings for dates, times and datetime values appropriate for the respective database types.
- All methods of Zend_Db_Adapters, Zend_Db_Table and Zend_Db_Select that handle parameter binding (such as, but not only, the Zend_Db_Adapter_Abstract::quote*() and Zend_Db_Adapter_Abstract::fetch*() families and the Zend_Db_Select::where() and having() methods, as well as the Zend_Db_Table magic setter methods) should be made capable of turning a given Zend_Date object into a date, time or datetime value appropriate to the respective database type.
- There should be methods named get(Date|Time|DateTime)Format() to enable the user to get the Zend_Date formatstring that is stored in the Zend_Db_Adapter.
- Setter-methods for these private properties should be explicitly prohibited.
The target of this improvement is to enhance the usability and interoperability of Zend_Date with databases, so that the user does not have to care about the right datetime value format for the database he/she is using. Also, through the formatstring getter-methods, the user should get an easy way to turn a column value which he/she knows is a datetime value back into a Zend_Date object. Setting these formatstrings must, of course, not be possible because they are database specific, and setting them to different values may lead to unexpected and unforeseeable results.
As this is database specific it would be best that each adapter know what date/time format he wants to have.
The handling within Zend_Date is quite easy...
$date = new Zend_Date($format, $dbformat); $databasevalue = $date->toString($dbformat);But also to mention...
The fastest way would be to have all dates extracted as unix timestamp from the database...
Each database also accepts timestamps as input for datetime fields.
This would mean that no parsing has to occur which would make the code much faster.
$date = new Zend_Date($format, $dbformat); $databasevalue = $date->toString($dbformat);