I am trying to use custom sorting in Doctrine 2 (using MySQL). Code looks somehow like this:
$queryBuilder->orderBy("i.type = 5, i.type = 3, i.type = 7");
The error I get is this one: [Syntax Error] line 0, col 72: Error: Expected end of string, got '='
.
I have found out that this is not possible because of compatibility with other database systems. So my questions is: How can do this in other way, directly in the query (if possible)?
Well, at the end, I haven't solution I wanted, but I had to do something else. At the end, the result was the desired one.
I selected the data normally and than by going throught the array and using array sort finished the job.
OK, so I don't know anything about doctrine, but I'll take a shot in the dark. The end result you need to order by a function in mysql will need to be something like ORDER BY FIELD(i.type,5,3,7)
So I'm guessing your line should be $queryBuilder->orderBy("FIELD(i.type,5,3,7)");