tags:

views:

115

answers:

1

im using doctrine-project

and i have 3 tables

table 1: post
--------------
postid , title , date , some more fields....


table 2: tags
---------------
tagid , title


table3: post_tags 
--------------------
post_tags_id , tagid , postid

table 3 is link between tags and posts which mean each post get tags through post_tags

now in base Post model i have :

     $this->hasMany('PostTags as TagLink', array(
            'refClass' => 'PostTags',
            'local' => 'postid',
            'foreign' => 'postid'
        )

    );

which links the model to PostsTags model

and in PostsTags model i have assc "belongs to" to Post model and Tag model

now im runing the query :

$q = Doctrine::getTable('posts')->findAll();

now if i want to get tags i do $q->PostsTags->Tags

but i dont really care about PostsTags becouse its only link

so i want to do just

$q->Tags

and getting taglist for the post

how can i do that ?

A: 

Doctrine Using Many-to-many

Doctrine Defining Many-to-many

prodigitalson
thank you very much , i didnt know what was the name of this kind of relation :)