Re: Newbie: Composition by Association - Pagination Class general question.
| From: | Stuart | Date: | Sun, 19 Jul 2009 14:43:58 +0000 |
| Subject: | Re: Newbie: Composition by Association - Pagination Class general question. | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295577@lists.php.net to get a copy of this message | ||
2009/7/19 MEM <talofo@gmail.com>:
>
>> I would say your pagination logic belongs in myPDO.class.php. Where I
>> have this functionality it's as simple as two arguments to the method
>> that gets data, $page and $perpage. Setting both to false would
>> retrieve all rows.
>
> Interesting but, still no clue, on this side, about how to accomplish that. I'm still a
> newbie.
> Can you throw some key words so that I can google them and look for a way to implement that?
I don't know much about PDO, but in raw MySQL SQL you'd have something
similar to this...
function Select($table, $where, $page = false, $perpage = 20)
{
$sql = 'select * from '.$table.' where '.$where;
if ($page !== false)
{
$sql .= ' limit '.(($page-1)*$perpage).', '.$perpage;
}
// now run the query and return the results
...
}
Obviously this is highly simplified but should give you the general
idea. If you still don't get it I suggest you find something open
source that does pagination (any blogging system should work as an
example) and look at the source code.
-Stuart
--
http://stut.net/