Hello, I have a similar problem, I have a table
Ads and a table Models The logic says an Ad has one Model and a Model belongs lo many Ads but when I put that logic in the model Ad I get a Unknown column 'Model.model_id'. but as beetlecube said is the table Ad which have the foreign key In this case HasMany asociation is not the case i think. do cake need to have tables linked that way or something ? Thanks! On 6 sep, 00:02, beetlecube <[EMAIL PROTECTED]> wrote: > Okay, thanks Grant. > > On Sep 4, 10:36 pm, Grant Cox <[EMAIL PROTECTED]> wrote: > > > You want Post belongsTo User, User hasMany Post. > > > On Sep 5, 3:25 pm, beetlecube <[EMAIL PROTECTED]> wrote: > > > > Hi, hope someone can clear this simple thing up. > > > > I have a Post model (posts table) > > > ------------------------- > > > Pri Key: int ID > > > varchar[100] comment > > > int User_id ( the user who posted it of course ) > > > > and a User model (users table) > > > --------------------------------- > > > Pri Key int ID > > > > varchar username .. other fields, too... > > > > On my Posts view thtml page, I need for my findAll (run from posts > > > controller of course) to get all of my Posts plus the User table > > > record that belongs to that post. > > > > But if I have a $hasOne in the Post model, the query attempts to join > > > the Post.ID field with User.user_id which doesn't work of course. > > > > But User table doesn't have any fields relating to posts at all. I > > > simply have a user_id in the posts table so that I know who posted > > > what. > > > > Do I need to just use the Execute api call from the Model class to > > > manually run this query? > > > > It looks like cakePHP is needing for the Post.ID field specifically to > > > link up to a foreign id in User. > > > > Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
