I'm using Zend Framework's Zend_Db_Table
classes to fetch data from a database.
I'd like to "refine" each row I fetch from a table by adding something to it. Within a plain old SQL query I would write eg. SELECT *, dueDate<NOW() AS isOverdue
. In this example, feeding an extra field to the SQL query would be possible, but sometimes it might be more suitable to do the extra stuff with PHP. Anyway, I'd use this information mainly in my views, eg. to highlight overdue items accordingly.
What would be a good place to add this isOverdue
data in a ZF application?
My thoughts so far:
- finding that ZF has a built-in mechanism for this (not successful so far)
- subclassing
Zend_Db_Table_Row
- overriding
_fetch()
in myZend_Db_Table
class - rethinking whether this is a sane pattern at all :)
As a bonus, it would be nice that I could still use ZF to update rows. Maybe this would be (another) reason for a naming convention for custom fields?