Re: Re[2]: displaying data from database

From: Date: Fri, 02 Nov 2001 21:22:55 +0000
Subject: Re: Re[2]: displaying data from database
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1823@lists.php.net to get a copy of this message
Make sure you are only selecting the data necessary for the page. Or yes, you could make a custom function for doing pagination of some sort. Alexander Plakidin wrote: > > (Monte, sorry, I sent a message personally, now re-posting to this list for discussion) > > Do you mean loading all the data which is needed to be displayed into an array? > I'm against this approach... I think, it is too memory-consuming. Am I wrong? > > Your example is surely helpful, and I WAS using something like this, I'm only worried if > it's effective! > > Alex. > > > 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 > >> http://www.phpinsider.com/php/code/Smarty/ > > > -- > > Monte Ohrt <monte@ispi.net> > > http://www.ispi.net/ > > -- > Ñ óâàæåíèåì, > Alexander mailto:alexp@mnc.md > > --- > 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 > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

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