Re: Relationship Confusion

2009-10-29 Thread John Andersen

Hi Dave,

Look in the cook book at:
http://book.cakephp.org/view/851/Multiple-relations-to-the-same-model

There it is explained how to do it!
Enjoy,
   John

On Oct 29, 4:29 pm, "Dave"  wrote:
> Can someone help me out with this situation. Will try to explain as simple
> as possible.
>
> User A creates an ad => he selling a lawnmower (Ads)
> User B views the ad belonging to User A and wants to click "Interested"
> which will make a record in the DB table called "Interests"
>
> I need the table to be accessed by both User A and User B for different
> reason. User A will see who is interested in his offers, and User B will see
> all the offers he is interested in.
>
> But how do you define that relationship? cant be 2 user_id's in the table..
> Interests Table:
> id
> seller_id => the ad owner user_id
> buyer_id => the interested user_id
>
> But the User to Interests relationship...how can you determine the keys for
> this?
>
> Thanks in advance for any help
>
> Dave
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Relationship Confusion

2009-10-29 Thread Dave

Can someone help me out with this situation. Will try to explain as simple
as possible.
 
User A creates an ad => he selling a lawnmower (Ads) 
User B views the ad belonging to User A and wants to click "Interested"
which will make a record in the DB table called "Interests" 
 
I need the table to be accessed by both User A and User B for different
reason. User A will see who is interested in his offers, and User B will see
all the offers he is interested in.
 
But how do you define that relationship? cant be 2 user_id's in the table..
Interests Table:
id
seller_id => the ad owner user_id
buyer_id => the interested user_id
 
But the User to Interests relationship...how can you determine the keys for
this?
 
Thanks in advance for any help
 
Dave 


--~--~-~--~~~---~--~~
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: Relationship confusion

2009-06-02 Thread Marcelo Andrade

On Sun, May 31, 2009 at 9:45 PM, Dave Maharaj :: WidePixels.com
 wrote:
> This is fairly simple question but I think saying it in my head and hearing
> it sounds wrong and confusing me further.
>
> "User" signs up and selects the "Group" they are going to belong to as they
> can only belong to one group...sounds fine when you say it out load
> "Group" has many "Users".sounds fine when you say it out load
>
> User belongsTo Group
> Group hasMany Users
>
> -- OR --
>
> "User" signs up and selects the "Role" they are going to have as they can
> have only 1 role sounds fine when you say it out load
> "Role" has many "Users' sounds wrong
>
> User hasOne Role
> Role hasMany Users
>
>
> So my question is how should this go?


I understood what did you mean.  But we don't have to
think in "Role hasMany User" as in ownership thought.

The "rule of thumb" is that the model that has a foreignKey
to another "belongsTo" that model, i.e., if the "User" needs
to know your Role, so the users table must have a role_id,
so "User belongsTo Role" and "Role hasMany (or even
hasOne if that's the case) User".

Got it? :-P

Best regards.

--
MARCELO DE F. ANDRADE
Belem, PA, Amazonia, Brazil
Linux User #221105

http://mfandrade.wordpress.com

--~--~-~--~~~---~--~~
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: Relationship confusion

2009-05-31 Thread Dave Maharaj :: WidePixels.com

Yes exactly the same thing...user can only have one role/groupjust
saying user can only have one group sounds wrong...whereas user belongs to a
group sounds right (as in English language sounds right) and confusing
myself further..

Basic ideas is user has 1 one role/group but I need a separate profile for
each user based on the role/group they have. What is the best way to set
that up?

Dave

-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: May-31-09 11:02 PM
To: cake-php@googlegroups.com
Subject: Re: Relationship confusion


role, group ... pretty much the same thing, no?

On Sun, May 31, 2009 at 8:45 PM, Dave Maharaj :: WidePixels.com
 wrote:
> This is fairly simple question but I think saying it in my head and 
> hearing it sounds wrong and confusing me further.
>
> "User" signs up and selects the "Group" they are going to belong to as 
> they can only belong to one group...sounds fine when you say it out 
> load "Group" has many "Users".sounds fine when you say it out load
>
> User belongsTo Group
> Group hasMany Users
>
> -- OR --
>
> "User" signs up and selects the "Role" they are going to have as they 
> can have only 1 role sounds fine when you say it out load "Role" has 
> many "Users' sounds wrong
>
> User hasOne Role
> Role hasMany Users
>
>
> So my question is how should this go?
>
> Dave
> >
>



--~--~-~--~~~---~--~~
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: Relationship confusion

2009-05-31 Thread brian

role, group ... pretty much the same thing, no?

On Sun, May 31, 2009 at 8:45 PM, Dave Maharaj :: WidePixels.com
 wrote:
> This is fairly simple question but I think saying it in my head and hearing
> it sounds wrong and confusing me further.
>
> "User" signs up and selects the "Group" they are going to belong to as they
> can only belong to one group...sounds fine when you say it out load
> "Group" has many "Users".sounds fine when you say it out load
>
> User belongsTo Group
> Group hasMany Users
>
> -- OR --
>
> "User" signs up and selects the "Role" they are going to have as they can
> have only 1 role sounds fine when you say it out load
> "Role" has many "Users' sounds wrong
>
> User hasOne Role
> Role hasMany Users
>
>
> So my question is how should this go?
>
> Dave
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Relationship confusion

2009-05-31 Thread Dave Maharaj :: WidePixels.com
This is fairly simple question but I think saying it in my head and hearing
it sounds wrong and confusing me further.
 
"User" signs up and selects the "Group" they are going to belong to as they
can only belong to one group...sounds fine when you say it out load
"Group" has many "Users".sounds fine when you say it out load
 
User belongsTo Group
Group hasMany Users
 
-- OR --
 
"User" signs up and selects the "Role" they are going to have as they can
have only 1 role sounds fine when you say it out load
"Role" has many "Users' sounds wrong
 
User hasOne Role
Role hasMany Users
 
 
So my question is how should this go?
 
Dave 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---