Re: displaying data from database
| From: | Monte Ohrt | Date: | Fri, 02 Nov 2001 21:13:13 +0000 |
| Subject: | Re: displaying data from database | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1820@lists.php.net to get a copy of this message | ||
Load them from the PHP script first, then call the template.
$smarty = new Smarty;
$db_vars = get_db_vars();
$smarty->assign("dbvars",$dbvars);
$smarty->display("index.tpl");
Alexander Plakidin wrote:
>
> Hi People,
>
> I'm new to Smarty (decided to migrate to Smarty from FastTemplate). Smarty really looks
> pretty cool, and I like it much more than FastTemplate. It seems to run much faster (I
> didn't do any tests, though), and provides alot of nice features.
>
> I am only wondering if I am using a right approach to display repeating data from
> database. I was researching docs - they all say that data should be firstly retrieved into
> an array, and then displayed with FastTemplate. Pretty simple, yeah... I just wonder if
> this method is efficient enough - it is possible that a big amount of data will be
> retrieved from database, and I am wondering if it can cause a slowdown. Can you, guys,
> tell me if I am wrong, and this approach is OK?
>
> I am currently using a scheme like this:
>
> {* firstly retrieve data from database *}
> {* this will run a query and assign a variable which contains number of rows *}
> {initiate_display}
>
> {section name=blabla loop=$numRows}
> {* here I jump to next record, and retrieve current row to $RECORD array}
> {next_record}
>
> {* and finally perform some output *}
> {$RECORD.id}. {$RECORD.title}<br>
> {/section}
>
> Actually, I don't like it as I have to write some custom functions, etc... Please point me
> to a right direction ;)
>
> Thanks,
> Alex.
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at =×Tm<�x-�Ô‹�
> Keîhttp://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/