Search code examples
phpsymfonydoctrine-orm

Invalid order by orientation


In my database I have the columns id, uid and data and I would like to sort id by DESC.

$this->getDoctrine()->getRepository(FormInputs::class)->findBy(['uid' => $uid], ['id', 'DESC']);

If I use the second parameter (['id', 'DESC']), I get the following error:

Invalid order by orientation specified for App\Entity\FormInputs#0

Why am I getting this error?


Solution

  • Try Passing that like

    $this->getDoctrine()->getRepository(FormInputs::class)->
    findBy(
      ['uid'=>$uid],
      ['id'=>'DESC']
    );