KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I can't seem to find any mention in the Doctrine documentation on how to check if an entity has an existing relationship to another entity: http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-associations.html In Doctrine 1.x there was a method called exists that could be called on an entity to check this: http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relations:clearing-related-records In Doctrine 2.0 this is what I've tended to do. What techniques are other people using? <?php class Group { private $id; protected $name; protected $users; public function __construct() { $this->colorgroups = new ArrayCollection(); } public function hasUsers() { return count($this->users) > 0; } }
Tags (comma-separated)
Save Edits
Cancel