Re: Smarty and PEAR DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Reynier Perez Mira <rperezm@xxxxxxxxxxxxxxxxxx>:
> 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.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux