Hi Alex/Jasper,

Just wanted to confirm with you guys on following stuff. Now i have to 
create the one-to-many self referencing association. Following are the 
details of table structure and annotations.

*table: groups*
id int(11) NOT NULL 
name varchar(50) NOT NULL 
parent_id int(11) NULL 
icon_id int(11) NULL

*table: group_members*
int int(11) NOT NULL 
group_id int(11) NOT NULL
user_id int(11) NOT NULL 
is_teacher int(11) NOT NULL

*Annotations*

*.....................groups.........................*
/**
 * @Entity @Table(name="groups")
 **/
class Group 
{
/**
     * @Id @Column(type="integer") @GeneratedValue
     * @var int
     */
    protected $id;

    /**
     * @Column(type="string")
     * @var string
     */
    protected $name;

    /**
     * @OneToMany(targetEntity="Group", mappedBy="class")
     **/
    private $groups;

    /**
     * @ManyToOne(targetEntity="Group", inversedBy="groups")
     * @JoinColumn(name="parent_id", referencedColumnName="id")
     **/
    private $class;

    /**
     * @Column(type="integer", nullable=true)
     * @var integer
     */
    protected $icon_id;

    public function __construct() {
        $this->groups = new ArrayCollection();
    }

*........................group_members..........................*
/**
 * @Entity @Table(name="group_members")
 **/
class GroupMember
{
/**
     * @Id @Column(type="integer") @GeneratedValue
     * @var int
     */
    protected $id;

    /**
     * @ManyToOne(targetEntity="Group", inversedBy="group_members")
     * @JoinColumn(name="group_id", referencedColumnName="id")
     **/
    private $group;

    /**
     * @ManyToOne(targetEntity="User", inversedBy="group_members")
     * @JoinColumn(name="user_id", referencedColumnName="id")
     **/
    private $groupuser;

I have to get list of all members by group id or name. Am unable to get it.

Thank you,
Swapna V

On Sunday, March 30, 2014 9:15:29 PM UTC+5:30, Swapna V wrote:
>
> Hi,
>
> I am new to doctrine world. I have problem with understanding many-to-many 
> associations. Following is my table structure:
>
> **users**
>
> id int(11) NOT NULL
>
> name varchar(50) NOT NULL
>
> role_id int(11) NOT NULL
>
> **roles**
>
> int int(11) NOT NULL
>
> role varchar(255) NOT NULL
>
> **relations**
>
> id int(11) NOT NULL
>
> name varchar(50) NOT NULL
>
> **relatives**
>
> id int(11) NOT NULL
>
> user_id int(11) NOT NULL
>
> relativeuser_id int(11) NOT NULL
>
> relation_id int(11) NOT NULL
>
> invitedby_id int(11) NULL
>
> according to above schema relatives columns user_id, relativeuser_id and 
> invitedby_id are foreign key from users table. And relation_id is foreign 
> key from relations table.
>
>
> Please help me creating associations for this table. (if you give answer 
> in yaml format will be helpful).
>
> Thank you,
>
> Swapna V
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to