mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
How to bind object params to raw sql #6575
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zmitic on GitHub (Nov 29, 2020).
Consider this simplified example:
This is very similar how pagination tools work, including one in Doctrine. The problem is that this will count all matches in table, thus making it pretty slow after few million rows.
And honestly; no one need something like
you have 1.200.000 resultsat the cost of speed. But having something likethere is more than 1.000 matches, please add more filtersis something usable.So I tried to limit COUNT and this worked:
but we can't put subquery in FROM.
Now here is the question; once I extract SQL from $qb and wrap it like in example, how do I bind object params and arrays to NativeQuery?
I tried everything for hours, probably running in circles now... SO didn't help and it is important to reduce load time.
The example is oversimplified, it is actually full of conditions based on filters user selected. But it is important to bind params like in
$qb->setParameter('user', $user).