ZF-10701: Zend_Db_Table doesn't handle Oracle DATE columns properly

Description

Zend_Db_Table / _Row does not appear to be properly understanding Oracle DATE columns; It's not reading any hours with the values.

Here's a full test code:

$db = new Zend_Db_Adapter_Pdo_Oci();

Zend_Db_Table::setDefaultAdapter($db);
$table = new Zend_Db_Table('TEST_DT');
$row = $table->fetchRow();

var_dump(Zend_Version::VERSION);
var_dump($row->TEST_DT);
var_dump( date('c', strtotime($row->TEST_DT)) );

Actual Output:

string(6) "1.11.0"
string(9) "17-NOV-10"
string(25) "2010-11-17T00:00:00-06:00"

Expected Output:

string(6) "1.11.0"
string(9) "17-NOV-10 09:00:00"
string(25) "2010-11-17T09:00:00-06:00"

Setup:

create table test_dt (
  a   number primary key,
  test_dt   date
)

Insert into TEST_DT
   (A, TEST_DT)
 Values
   (1, TO_DATE('11/17/2010 09:00:00', 'MM/DD/YYYY HH24:MI:SS'));

(Note, 'A' column is required, or make test_dt primary, as Zend_Db_Table requires all tables to have a primary key)

Comments

THis is default behavior in Oracle. In Oracle SQL-developer you get the same results for the query.

If you want another date-format you must alter your query to something like


TO_CHAR( TEST_DT , 'MM/DD/YYYY HH24:MI:SS' )

for the date field.

I understand this is the default Oracle behavior. The issue is 1) this is a Zend_DB_Table instance. Zend_DB_Table gets the metadata of the table; it knows it's a DATE column. It needs to be smart enough to knows that Oracle's date/time is handed in this aspect. 2) per your suggestion, because it is a Zend_DB_Table instance, I do not have access to the query that's being used. I can't make that modification.