Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
Created September 18, 2014 12:13
Show Gist options
  • Select an option

  • Save webdevilopers/a2ddf5f9d721db5795c4 to your computer and use it in GitHub Desktop.

Select an option

Save webdevilopers/a2ddf5f9d721db5795c4 to your computer and use it in GitHub Desktop.
Single and Multiple Ordering To-Many Associations in Doctrine2
/**
* @ORM\Entity
* @ORM\Table(name="branches")
*/
class Branch
{
/**
* @ORM\OneToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="branch")
* @ORM\OrderBy({"lastName" = "ASC", "firstName" = "ASC"})
*/
private $users;
}
/**
* @ORM\Entity
* @ORM\Table(name="branches")
*/
class Branch
{
/**
* @ORM\OneToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="branch")
* @ORM\OrderBy({"lastName" = "ASC"})
*/
private $users;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment