Is there any way to set a global variable into DQL?
I've this code in SQL (working like charm) that I've to translate to DQL. It isn't returning any result, just perform action and finish.
//COPIAR A RANKANTERIOR
UPDATE SistemaPuntuacions SET rankingAnterior = rankingActual
//ACTUALITZAR SEGONS ELS PUNTS DEL USUARI
set @rank=0;
UPDATE SistemaPuntuacions SET rankingActual= @rank := @rank +1
ORDER BY punts DESC;
I can't find any documentation related to that...
//Copy to oldRank
UPDATE RankSystem SET oldRank = RankNow
//Update RankNow by points
set @rank=0;
UPDATE RankSystem SET RankNow= @rank := @rank +1
ORDER BY points DESC;
DQL is Doctrine Query Language http://docs.doctrine-project.org/en/2.1/reference/dql-doctrine-query-language.html
So DQL is actually a query language and not suited for handling global variables. You can query databases and manipulate them, that's it.
In DQL you can define parameters to be passed to your query , Doctrine2 using setParameters
However where is your actual DQL code?
Besides try to have your code comments and keywords to be in english to make it understandable for us.
You don't need to translate it in dql, you can use native query, too. Have a look here
I need to put SQL native in query Builder Doctrine2
Using native SQL query without entity class
Hope that helps!