We are using the doctrine pagination tool for faster queries in paginated results.
But doctrine is now creating the following query:
SELECT DISTINCT id0 FROM (
SELECT c0_.id AS id0, c0_.number AS number1
FROM cudi.stock_orders_items c0_
INNER JOIN cudi.stock_orders c1_ ON c0_.order_id = c1_.id
WHERE c1_.date_ordered IS NOT NULL AND c1_.date_ordered > $1 AND c1_.date_ordered < $2
ORDER BY c1_.date_ordered DESC
) dctrn_result LIMIT 25 OFFSET 50
But due to the distinct, the order is lost and the results are not sorted by date_ordered anymore. How can this be solved?