Re: multiple many to many tables between the same tables cakePHP

2010-03-18 Thread John Tadros

I really don't know how to thank you
I will try it as soon as i get home
Thanx alot

John
On 3/18/10 10:22 AM, WebbedIT wrote:

Heres a quick stab at it

Tables:
musics
users
musics_ratings
musics_privacies

Music model HABTM
'Rating' =>  array(
   'className' =>  'User',
   'joinTable' =>  'musics_ratings',
   'with' =>  'MusicsRating',
   'foreignKey' =>  'music_id',
   'associationForeignKey' =>  'user_id',
   'unique' =>  true
 ),
'Privacy' =>  array(
   'className' =>  'User',
   'joinTable' =>  'musics_privacies',
   'with' =>  'MusicsPrivacy',
   'foreignKey' =>  'music_id',
   'associationForeignKey' =>  'user_id',
   'unique' =>  true
 )


User model HABTM
'Rating' =>  array(
   'className' =>  'Music',
   'joinTable' =>  'musics_ratings',
   'with' =>  'MusicsRating',
   'foreignKey' =>  'user_id',
   'associationForeignKey' =>  'music_id',
   'unique' =>  true
 ),
'Privacy' =>  array(
   'className' =>  'Music',
   'joinTable' =>  'musics_privacies',
   'with' =>  'MusicsPrivacy',
   'foreignKey' =>  'user_id',
   'associationForeignKey' =>  'music_id',
   'unique' =>  true
 )

MusicsRating model
class MusicsRating extends AppModel {

   var $belongsTo = array(
 'Music',
 'User'
   );

}

MusicsPrivacy should not need creating

You may want to then read the following for assistance on saving the
extra field
http://teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-join-table-for-habtm-models/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
   


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: multiple many to many tables between the same tables cakePHP

2010-03-18 Thread WebbedIT
Heres a quick stab at it

Tables:
musics
users
musics_ratings
musics_privacies

Music model HABTM
   'Rating' => array(
  'className' => 'User',
  'joinTable' => 'musics_ratings',
  'with' => 'MusicsRating',
  'foreignKey' => 'music_id',
  'associationForeignKey' => 'user_id',
  'unique' => true
),
   'Privacy' => array(
  'className' => 'User',
  'joinTable' => 'musics_privacies',
  'with' => 'MusicsPrivacy',
  'foreignKey' => 'music_id',
  'associationForeignKey' => 'user_id',
  'unique' => true
)


User model HABTM
   'Rating' => array(
  'className' => 'Music',
  'joinTable' => 'musics_ratings',
  'with' => 'MusicsRating',
  'foreignKey' => 'user_id',
  'associationForeignKey' => 'music_id',
  'unique' => true
),
   'Privacy' => array(
  'className' => 'Music',
  'joinTable' => 'musics_privacies',
  'with' => 'MusicsPrivacy',
  'foreignKey' => 'user_id',
  'associationForeignKey' => 'music_id',
  'unique' => true
)

MusicsRating model
class MusicsRating extends AppModel {

  var $belongsTo = array(
'Music',
'User'
  );

}

MusicsPrivacy should not need creating

You may want to then read the following for assistance on saving the
extra field
http://teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-join-table-for-habtm-models/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: multiple many to many tables between the same tables cakePHP

2010-03-17 Thread John Tadros
Hello All,

Thanks for your replies.
But to make sure that I get things right, you mean that I should create a
table called "Ratings" and a table called "Privacies" and link "users" and
"musics" each with a Many to many relations to each of Ratings and privacies
?

Actually in my case, the table musics_users_privacy does not contain an
attribute for privacy, so i can just ignore it in the naming, but in Ratings
I should have three tables "Ratings", "Musics" and "Users" and then have
"Musics_Ratings" and "Users_Ratings" tables along with their models

Is that correct ?

Best Regards
John

On Wed, Mar 17, 2010 at 10:22 AM, WebbedIT  wrote:

> They are two relations so you have two join tables, you just need to
> define different join tables in each association, plus you need to
> create a model for the ratings join model as Mateo states above to
> allow for the rating attribute.
>
> HTH
>
> Paul
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Re: multiple many to many tables between the same tables cakePHP

2010-03-17 Thread WebbedIT
They are two relations so you have two join tables, you just need to
define different join tables in each association, plus you need to
create a model for the ratings join model as Mateo states above to
allow for the rating attribute.

HTH

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: multiple many to many tables between the same tables cakePHP

2010-03-16 Thread Mateo San Román
Hello,

Since you are adding attributes to a relation, it will not be a pure
"bridge table".
You should create a table called "Ratings" with an attribute and the
relations to musics and users tables, so it could have a view where
you can add the rating attribute. Same for Privacy table.

On 16 mar, 11:02, John Tadros  wrote:
> Hello All,
>
> I currently have 2 tables: users & musics
> I want to have two different Many To Many relations between them:
>
> users_musics_rating which would store the user's rating for a specific
> music
> users_musics_privacy which determines which user should see a specific
> music
>
> how can this be done in cakePHP ? as I found in the documentation many
> to many tables are defined by the name of first table_name of second
> table
>
> So how to hanlde that in my case ?
>
> Best Regards
> John

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


multiple many to many tables between the same tables cakePHP

2010-03-16 Thread John Tadros
Hello All,

I currently have 2 tables: users & musics
I want to have two different Many To Many relations between them:

users_musics_rating which would store the user's rating for a specific
music
users_musics_privacy which determines which user should see a specific
music

how can this be done in cakePHP ? as I found in the documentation many
to many tables are defined by the name of first table_name of second
table

So how to hanlde that in my case ?

Best Regards
John

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en