Jump to content

Changing sorting order in pagination class


saynotojava

Recommended Posts

I am using following pagination class: https://github.com/BenGriffiths/pdo-mysqli-pagination and i have specific situation where i cant use ordering inside mysql query. How do i change sorting in this pagination class, where  loading first page wont load first page but last page instead ? (that way i'l get proper sorting)

Edited by saynotojava
Link to comment
Share on other sites

16 hours ago, requinix said:

If you can't sort in the query then you have to retrieve all the data and do all the work yourself. And that is a terrible thing to be forced into.

Why do you say you can't do it in a query?

It's a specific query in specific situation which require order by NULL to make it work properly. It does sounds like a terrible thing, but since i have this class already, it should be possible to reverse page output, so page 1 become page 10,page 2 become 9 and so on.

Link to comment
Share on other sites

27 minutes ago, requinix said:

But... if it's already sorting by the correct criteria just in the wrong order, then all you have to do is reverse the order.

What's your code? Maybe it will be easier to understand your problem if we can see that.

There is not much difference between example code and my code, only difference is sql query and obviously HTML layout. Everything else is same as in example code.

Link to comment
Share on other sites

7 minutes ago, Barand said:

Apparently SQLServer queries involving ROW_NUMBER column in the output requires an ORDER BY to be specified, even if it is a dummy one like "ORDER BY NULL". This could be one of those situations, but at the moment it's just speculation.

Actually,  when i tested different queries,  when you dont specify ORDER in query, by default it order by ID(alias first column). So if you dont want ORDER to run , then you need to specify NULL.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.