Created
June 29, 2011 15:57
-
-
Save MitMaro/1054156 to your computer and use it in GitHub Desktop.
Doctrine Join Table Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Entity | |
*/ | |
class User { | |
// ... | |
} | |
/** | |
* @Entity | |
*/ | |
class UserNetwork { | |
/** | |
* @Column(type="boolean") | |
*/ | |
protected $isAdmin; | |
// ... | |
} | |
/** | |
* @Entity | |
*/ | |
class Network { | |
/** | |
* @ManyToMany(targetEntity="User") | |
* @JoinTable( | |
* name="network_user", | |
* joinColumns={ | |
* @JoinColumn(name="network_id", referencedColumnName="id") | |
* }, | |
* inverseJoinColumns={ | |
* @JoinColumn(name="user_id", referencedColumnName="id") | |
* } | |
* ) | |
*/ | |
protected $users; | |
/** | |
* @ManyToMany(targetEntity="User") | |
* @JoinTable( | |
* name="network_user", | |
* joinColumns={ | |
* @JoinColumn(name="network_id", referencedColumnName="id", filter="isAdmin=true") | |
* }, | |
* inverseJoinColumns={ | |
* @JoinColumn(name="user_id", referencedColumnName="id") | |
* } | |
* ) | |
*/ | |
protected $admins; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment