Reputation: 494
I have the following problem. I have 2 entities that are in a ManyToMany relation and I would like to sort them for a certain key word sequence.
Team.php
/**
* @ORM\ManyToMany(targetEntity="Domain\Entity\Player")
* @ORM\JoinTable(name="match_substitute_player_home")
*/
public $substitutePlayersHome;
and now iam tring these to order it
/**
* @ORM\ManyToMany(targetEntity="Domain\Entity\Player")
* @ORM\JoinTable(name="match_substitute_player_home")
* @ORM\OrderBy({"FIELD(type, {'keep','def','atk'})"})
*/
public $substitutePlayersHome;
My question is how to use the OrderBy Annotation right for a string value list.
It have to be some line like this, but this line dont work:
* @ORM\OrderBy({"FIELD(type, {'keep','def','atk'})"})
sources of my tests:
-> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/ordered-associations.html
-> https://symfony.com/doc/current/doctrine.html
Upvotes: 0
Views: 243
Reputation: 836
The FIELD property is not defined by default in doctrine. Download and try this plugin. https://github.com/beberlei/doctrineextensions
Configure the package manually:
doctrine:
orm:
dql:
string_functions:
field: DoctrineExtensions\Query\Mysql\Field
Upvotes: 1