Answer the question
In order to leave comments, you need to log in
What would a query with QueryBuilder look like?
I have a sql query
SELECT game.* FROM game f
JOIN ( SELECT RAND() * (SELECT MAX(id) FROM game) AS max_id ) AS m
JOIN game_buffer on game_buffer.game_id = f.id
WHERE f.id >= m.max_id and f.`start_time` between :from
and :to and game_buffer.source_id = :source ORDER BY f.id LIMIT 1
JOIN ( SELECT RAND() * (SELECT MAX(id) FROM game) AS max_id ) AS m
Answer the question
In order to leave comments, you need to log in
Not directly, because DQL doesn't have a RAND()
. If you want, you can add your .
Also, although subqueries can be done through QueryBuilder, the resulting construction will look very strange. In addition, it is important to remember that QueryBuilder is a query building tool, for example, if you need to add some parts of the query depending on the application logic. If the query itself is static, then it is quite possible to use DQL directly. QueryBuilder is compiled into it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question