|
Nick, At my workplace, I implemented an ActiveRecord-like class (named db_object) that used to work exactly as you've described - namely, prior to every query to fetch actual record data, a call to SHOW COLUMNS FROM table name would be required. Very quickly we realized that this was doubling the number of queries needed to do anything. We got around this by actually caching the result of the SHOW COLUMNS call per each request, and then simply checking for the presence of this key (the table name) within the cache. If it existed, we used the cached result. This boosted performance significantly, such that, per page request, only one call to the table structure was needed for each table, no matter how many records from that particular table were needed. One important point to emphasize is that, while initially ORM (I think this is the term thrown around on the list - Object-Relational Mapping) may take a performance hit in simple situations due to operational overhead, in larger & more advanced setups it can be optimized in far more ways than a traditional setting, because you can abstract out the retrieval and cache entire result sets, or composed pages, and so on. Additionally, ORM will enforce consistent queries, enable (but not force) higher security standards due to consistency of query structure and actually lets the programmers work on writing their code efficiently, and the database blokes (such as myself) can work behind the scenes transparently optimizing the internals of how the object-oriented abstractions work. In fact, one of my upcoming projects is to allow db_object to transparently access foreign keyed records much like Ruby on Rails' ActiveRecord does. This would have been unthinkable had we not abstracted the interface out to an object. Just recently, I added a db_recordset object to our database tools, which implements the PHP5 interfaces of Iterator, ArrayAccess, & Countable. I hoping to try to contribute a similar enhancement to the existing Zend_Db_Table_Rowset object, because the usage through these interfaces is very intuitive, at least for me. Let it be known that I am not advocating completely dropping performance optimization in preference of abstractions, but rather, I would like to say the two are not mutually exclusive, but rather, they are complimentary in a well-designed system, and can yield a superior result when combined intelligently. *descends from soap box* Nick Lo wrote: I've just recently had time to test out Zend_Db_Table and while I realise it has a new proposal (which I can't get to right now as the wiki appears to be down) I'm curious as to how many are really using or planning to use it? |
- Re: [fw-general] Anyone using/planning to use Zend_Db_... Abu Hurayrah
- Re: [fw-general] Anyone using/planning to use Zen... Markus Wolff
- Re: [fw-general] Anyone using/planning to use... Abu Hurayrah
- Re: [fw-general] Anyone using/planning to use... Stefan Koopmanschap
- RE: [fw-general] Anyone using/planning to... Simon R Jones
- Re: [fw-general] Anyone using/planning to... Chris Hartjes
- RE: [fw-general] Anyone using/plannin... Simon R Jones
- Re: [fw-general] Anyone using/planning to use... Federico Galassi
- Re: [fw-general] Anyone using/planning to use Zen... Nick Lo
