Re: [SMARTY-DEV] feature request

From: Date: Mon, 05 Jan 2004 09:47:37 +0000
Subject: Re: [SMARTY-DEV] feature request
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2022@lists.php.net to get a copy of this message
Peter Billen wrote:
Besides this, I don't know if this is a good method of programming: a template may ask, for example, 'topic_name' and I detect that variable isn't set yet => I get it from the database. But after this, the template asks for 'topic_text' and I detect again that variable isn't set yet => I get it from the database. But now I have 2 queries (for 'topic_name' and 'topic_text') which could be combined into one query => overhead because in this situation 2 queries will take more time than 1 query.
That's it... this isn't a good method of programming. The template mustn't control what is assigned to itself, and accessing the database from within the template on-demand is _really_ bad style. I'm sorry, but your proposal doesn't comply with the idea of separation of presentation and application logic ;-) David
Hi Peter, What you're describing is usually known as lazy evaluation, i wouldn't say it was bad programming style, the separation is still there, the only difference being the time of evaluation of the variables. To implement this in Smarty would probably require some work on the compiler, an alternative may be to use method calls on objects from within your templates: http://smarty.php.net/manual/en/advanced.features.php -- Mark Gibson <gibsonm@cromwell.co.uk> Web Developer & Database Admin Cromwell Tools Ltd. Leicester, England.

« previous php.smarty.dev (#2022) next »