php - How to order one-to-one entity by Doctrine 2 ORM?
Get the solution ↓↓↓How to order by DESC one-to-one entity by Doctrine 2 ORM?
namespace Answer;
use Doctrine\ORM\Mapping as ORM;
class Answer {
...
/**
* @var Content
* @ORM\OneToOne(targetEntity="Answer\Content", mappedBy="answer")
* @ORM\OrderBy({"creationDate" = "DESC", "contentId" = "DESC"})
*/
protected $currentContent;
...
}
"OrderBy" annotation worked with one-to-many and many-to-many associations only.
Answer
Solution:
You have the answer in your question. The ORDER BY is applicated to the currentContent but if you have just one association (so with a OneToOne) you have just one entity of currentContent to sort so the ORDER BY isn't effective.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: failed to create image decoder with message 'unimplemented'
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.