whiteoctober / Pagerfanta

Pagination for PHP.
Other
1.59k stars 2 forks source link

Get page by element. #246

Closed CoalaJoe closed 9 months ago

CoalaJoe commented 6 years ago

I'm currently at the point of which I have to get the page number by the entity (DoctrineORMAdapter).

What are my options? Is there a way to get the offset of an entity by query?

sampart commented 6 years ago

Hi @CoalaJoe. There's no "get page number" method built into the adapters, I'm afraid. You'd need to run a custom query for this.

I don't have time to work out the exact code you'd need, sorry. But assuming you know the ID of the entity, you could basically retrieve all IDs into an array, get the index of the one you care about and then use that to work out what page it would be on.

Hope this helps. Sorry not to have more detail for you.

CoalaJoe commented 6 years ago

@sampart Thanks. Not the answer I was hoping for.

Performance is not critical in my application.