Reply to Re: Complicated pagination logic problem

Your name:

Reply:


Posted by comp.lang.php on 10/03/06 20:12

mootmail-googlegroups@yahoo.com wrote:
> comp.lang.php wrote:
> >
> > However, to paginate to the next page, you'll have to have had stuffed
> > THE ENTIRE RESULTSET into a $_SESSION variable and splice that.
> >
> > That of course is not good. But what on earth else do I do? If I am not
> > to use $_SESSION, how would I paginate such an exotic resultset?
> >
> > Thanx
> > Phil
>
> There is no reason to stuff the whole array into the session.
>
> This is no different than any other pagination implementation except
> that the data is the combination of two different data sources (but
> that fact does not change the difficulty at all). Treat this exactly
> as if you were just paging records in a database:
> -On each page, limit your output to X elements
> -On the link to the 'next' page, pass along an argument which contains
> the id (in this case, either the filename or the index of the array
> element) with which to begin displaying items on the following page.
> -Then, on the next page load, regenerate your array and begin
> displaying from the provided id value.
>
> When you're paging records from a database you don't store the entire
> resultset in the session, so why would you do any different here?

Because your approach would only optimally work if:

1) Every single image had metadata
2) Or not every image had metadata but there is no other sorting taking
place except for default sorting by image name

Because the moment I try to sort by a field other than image name, like
"image_location_country", the metadata fields should be first followed
by the non-metadata array, and with pagination, you are certain to lose
an image or two in your display because of that, and I honestly cannot
fathom a way to prevent that from happening.

I could only think of two solutions:

1) You stuff everything into $_SESSION and pull from there, sorted,
paginated and all
2) You constantly pull ALL images from /your_directory and ALL images
from the database where image_path LIKE '/your_directory/%' and combine
them into a temporary table, and from there, sort, paginate and voila!

Phil

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация