I have the following code in Doctrine:
return $this->createQueryBuilder('t') ->where('t.status LIKE :status') ->orderBy('t.createdAt', 'DESC') ->setParameter('status', $status) ->setMaxResults($limit) ->getQuery() ->getResult() ; However the real SQL query I want to build is this:
SELECT t.*, IF(deleted = 1, 4, status) AS status FROM trm t WHERE status = 3 ORDER BY created_at DESC; Essentially replacing the status column with one that = 4 if the column 'deleted' is true.
How can I recreate this in the doctrine query above?
I have tried looking into ->expr()->eq but I can't find any easy examples to follow. Im not even sure if they are what I need to use.