Re: [SMARTY] SQL-querys in templats

From: Date: Mon, 22 Apr 2002 23:00:07 +0000
Subject: Re: [SMARTY] SQL-querys in templats
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3844@lists.php.net to get a copy of this message
Although I share this concepts (written below), I think sometimes you may have very good reason to do so :)) I recommend to execute your query in PHP realm, and use Smarty to make the output. But fetching rows from DB and populating an array just to store till Smarty traverse it ... So, <?php /* ... */ $result = pg_exec($conn, "SELECT..."); $smarty->assign('result', $result); /* ... */ $smarty->display(); ?> {-section name=fetch start=0 max=$result|pg_numrows-} {-assign var="row" value=$result|pg_fetch_array:$smarty.section.fetch.index:PGSQL_ASSOC-} {-$row.column1-} {-$row.column2-} {-$row.column3-} {-/section-} ----- Original Message ----- From: "Jason Sweat" <sweatjejm@mchsi.com> To: "Marcel Güttler" <guettler@kemper-schlomski.de>; <smarty-general@lists.php.net> Sent: Friday, April 19, 2002 1:35 PM Subject: Re: [SMARTY] SQL-querys in templats | This kind of thing (loading data from a database) is usually done in the php | script that calls Smarty, not in the template itself. | One of the principal ideas behind Smarty is to separate the skill sets of | the Developer (php, sql) and the Designer (html). Examples of use of Smarty | w/ DB can be found at http://www.zend.com/zend/tut/tutsweatpart1.php . | | Regards, | | Jason | ----- Original Message ----- | From: "Marcel Güttler" <guettler@kemper-schlomski.de> | To: <smarty-general@lists.php.net> | Sent: Friday, April 19, 2002 6:19 AM | Subject: [SMARTY] SQL-querys in templats | | | > Greetings, | > | > is where a function in Smarty to loop throw a query by using template | code, | > like: | > | > {sql qury="select * from table" name=submenu loop=$subimages} | > | > {section name=submenu loop=$subimages} | > $subimages[submenu].url} - {$subimages[submenu].caption} | > {/section} | > | > | > thanks, | > | > Marcel | > | > | > | > | > -- | > Smarty General Mailing List (http://smarty.php.net/) | > To unsubscribe, visit: http://www.php.net/unsub.php | > | > | | | -- | Smarty General Mailing List (http://smarty.php.net/) | To unsubscribe, visit: http://www.php.net/unsub.php |

« previous php.smarty.general (#3844) next »