Doctrine that organizes many associations in essence

I want to order the OneToMany association in essence with a slight caveat that the specific property that I would like to order is not part of this object, but rather a property of what it is associated with.

Sorry for the confusing start, try to clarify the situation with the example. I would like to be able to do something similar to:

class download
{
    /**
     * @ORM\OneToMany(targetEntity="entity\download\file", mappedBy="download", indexBy="id")
     * @ORM\JoinColumn(name="download_id", referencedColumnName="download_id")
     * @ORM\OrderBy({"mime_type.extension" = "ASC"})
     */
    protected $files = null;
}

Where a downloadhas a lot filesand everyone filehas onemime_type

I'm finishing now ORMException: Unrecognized field: mime_type

Is this possible, or am I just asking too much?

+4
source share
2 answers

http://doctrine-orm.readthedocs.org/en/latest/reference/annotations-reference.html#annref-orderby

DQL OrderBy , ASC/DESC. (,). targetEntity @ManyToMany @OneToMany .

extension ( file). mime_type, . , @OrderBy .

, extension ( mime_type) file.

 * @ORM\OrderBy({"extension" = "ASC"})
+5

, , : OrderBy , DQL-, :

SELECT d
FROM download AS d
LEFT JOIN files AS f
LEFT JOIN mime_type AS m
ORDER BY m.extension
+3

Source: https://habr.com/ru/post/1545098/


All Articles