Re: Re: Smarty and PEAR DB

From: Date: Mon, 11 Apr 2005 20:13:15 +0000
Subject: Re: Re: Smarty and PEAR DB
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-212837@lists.php.net to get a copy of this message
Matthew Weier O'Phinney wrote:
* Reynier Perez Mira <rperezm@estudiantes.uci.cu>:
I'm using PEAR DB and Smarty. The case is that I have to pass a value = from a query result to a Smarty var. I try to paginate results. See the = code below: /////////////////////////////////////////////////////////////////////////= SmartyPaginate::connect(); SmartyPaginate::setLimit(5); $gbresult =3D $database->query("SELECT * FROM libro_de_visitas LIMIT " . = SmartyPaginate::getCurrentIndex() . "," . SmartyPaginate::getLimit()); $gbtotal =3D $database->query("SELECT COUNT(*) AS total FROM = libro_de_visitas"); $gbtotal->fetchRow(); SmartyPaginate::setTotal($gbtotal['total']); /////////////////////////////////////////////////////////////////////////= As you can see I need the COUNT value but I not know how get it from = query using PEAR. Some body can help me?
You'll need to do two different queries, one that counts the number of total results for the criteria, and one that pulls the set with a LIMIT statement. That is definitely not a Good Thing. I did that with an employer's site and database performance suffered having to always count and recount the records in question.


« previous php.general (#212837) next »