Fetching only some fields in Zend_Db_Table
As a rule, I like to use Zend_Db_Table for my database work. It's a nice, abstracted layer that keeps me from having to mess with SQL.
It's got a couple drawbacks, and one of them is that it fetches every column every time, which makes every DBA I work with grind their teeth. I'd like a method that limits the query to only columns I need. The result of the query would be limited Zend_Db_Table_Row objects (or a rowset of them) that would only give information on some columns and maybe couldn't be saved.
So is there a method to limit columns on Zend_Table_Row fetches and I just haven't figured out what it is? Has anyone already written such a method? Would anyone like to have it if I write such a method myself?
I imagine someone will say, "Well, if you only want to query a couple columns, why don't you use a different method?" I believe that, in an environment with several coders, it's better to keep the database API consistent. If a set of developers who don't know Zend_Framework find they have to learn Zend_Db_Tables to fetch and create records and then have to learn to do raw selects to fetch limited records, sooner or later, some of them might get frustrated and start sending all their queries to the adapter.
|