ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  The Dynamic Duo of PEAR::DB and Smarty
Subject:   Too much overhead...
Date:   2005-03-07 09:20:22
From:   gagari
I have been thinking a lot in that problem of integrate PEAR::DB and SmartyTemplate. The approach of the article is interesting in terms of software engeneering, but it doesn´t consider the overhead generated in the process. I mean, when you call a "getAll()" (and similars) it iterates over the DB resource putting the results in an array. Later, when you assign that array to the template it will, again, iterate over the array to fill the data on template. In a small resultset the overhead is insignificant, but in a larger resultset you may be duplicating the execution time. Perhaps it makes sense if between the two blocks of iterations you will be making some kind of validation. However in the most of cases you just want to paste the resultset data on the template.

I am working on the idea of fetch the resultset directly on the template (maybe using the plugin engine). We could use the proxy design pattern, or something like that, to develop a class that Smarty see as a data container, but as a matter of fact it uses the resultset to retrieve data.

Would you give some ideas?