2009/7/19 MEM <[email protected]>:
>
>> 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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php