On Tue, 03 Aug 2004 20:52:23 +1000, Ross Honniball <[EMAIL PROTECTED]> wrote: > Hi all, > > I use the LIMIT statement to control paging of data, which works really well. > > I now have a situation where I need to use some logic in addition to the > query that will result in NOT ALL records being spat out. ie. > > select * from x where y; > foreach result > if (some condition) > output; > endif > endfor > > So problem is I can't say LIMIT 20,20 on the query as logic may result in > less than 20 records being spat out to screen. > > I was planning on coding up a solution so that i just keep a count myself > of how many records I have output myself and break at appropriate paging > points, but I am probably re-inventing the wheel. > > Anyone know of any good classes they are using that do this sort of thing > already?
Just a quick note as no one else suggested it. You could also used stored procedures for this sort of thing if you can't get a good SQL solution. Even if you get an SQL solution, stored procedures can easily be faster (as they use program code). It would also be dropping records on the server side so that it doesn't have to be sent to your PHP app. My $0.02. -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php