whiteoctober/Pagerfanta

Get page by element.

Closed this issue · 2 comments

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?

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.

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

Performance is not critical in my application.