Re: [SMARTY] Paging Records Help please

From: Date: Sun, 09 Jan 2005 17:21:00 +0000
Subject: Re: [SMARTY] Paging Records Help please
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12130@lists.php.net to get a copy of this message
Jim MacDiarmid wrote:
I'm new to Smarty and I'm having some serious trouble getting adjusted to how things work. I'm using the PEAR::DB object to pull data from my database. I'd like to be able to show a paged list of the data. Will I need to use 2 queries if I want to have a page index? One query for the page index and one for the list? I'm attempting to use PEAR's DB_Pager.
Hi Jim, its generally a good idea to read the crashcourse http://smarty.php.net/crashcourse.php before writing applications. After that its more of a pear thing your asking about. In my opinion DB_Pager isn't efficient, use PEAR::Pager instead. After installing with pear install Pager there will be a Pager folder inside your PEARs doc-folder. Look at the example Pager_Wrapper, there is a function called Pager_Wrapper_DB() which returns an array. You just have to assign this array to your template instance with e.g. $smarty->assign('pageData', Pager_Wrapper_DB($db, $sql, $pagerParams)); In your template you can loop with $pageData.data. For further information please use the great smarty and pear documentation at http://smarty.php.net/ and http://pear.php.net/. hth André ps: please write a new message instead of answering one, if you change the topic.

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