0

Can anybody please say to me, how i can use Doctrine Extension? I see in DoctrineExtensions folder file Field.php, how i can use its functionality to set ORDER BY FIELD(id, 2,1,3), for example?

My query:

 $queryBuilder->select("t")->from('\Common\Model\Entity\Ticket', "t")->where("t.id IN (282,283,281)")
            ->addOrderBy('FIELD(t.id,' . implode(',', array(282,283,281)) . ')');

I am got error:

[Syntax Error] line 0, col 86: Error: Expected end of string, got '('

But it does not work. A lot of thanks and sorry for my poor english.

And it is not duplicate. I want to cnow HOW i can (what i myst do) to use Field.php Doctrine Extension

Nikoole
  • 4,553
  • 4
  • 18
  • 23
  • 1
    Please improve your question by posting all relevant **error messages** exactly as they appear. – Touki Jan 17 '14 at 15:08

1 Answers1

0

Debug your full query with this:

$queryBuilder->select("t")->from('\Common\Model\Entity\Ticket', "t")->where("t.id IN (282,283,281)")
        ->addOrderBy('FIELD(t.id,' . implode(',', array(282,283,281)) . ')');
print $queryBuilder->getQuery()->getSQL();
die();

And output your full query for more analysis, please.

Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91
  • Victor, please, check out my question. I am got error on FIRST line... I am cant getQuery() , or getQuery()->getResult()... I want to know what i must do to use Doctrine Extension called Field.php in DoctrineExtensions folder... – Nikoole Jan 18 '14 at 07:33