| Andre Gemünd 2005-01-09, 3:58 pm |
| 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.
|