CakePHP - Relationship Question - Posts.Child belongsTo User, How to define?

You put it in the Children model var $belongsTo = array( 'Post' ) By the way, what you posted is the model, not the controller. Hopefully it's just a typo and you have that in the correct place It's also unclear if you call the model "Child" or "Children". The $hasMany relationship is uses Children but in the question you say Posts.

Child do you have the inflection set up correctly? EDIT: I may have misunderstood the question: if you want a hasMany relationship, you already have that. The problem is either in the way you retrieve the data or in the relationship definition.

You put it in the Children model. Var $belongsTo = array( 'Post' ); By the way, what you posted is the model, not the controller. Hopefully it's just a typo and you have that in the correct place.It's also unclear if you call the model "Child" or "Children".

The $hasMany relationship is uses Children, but in the question you say Posts. Child -- do you have the inflection set up correctly? EDIT: I may have misunderstood the question: if you want a hasMany relationship, you already have that.

The problem is either in the way you retrieve the data or in the relationship definition.

Yes typo, thanks;) – DJDonaL3000 Aug 8 at 15:11 Above is the Post Model. I don't have any other Models relating to Posts, should I have another seperate model for the children? – DJDonaL3000 Aug 8 at 15:22 If you want to have the Children belongsTo Post relationship, then yes, you need the Children model.(What do you mean "not any other model relating to Posts"?

You have the User model related, right? ) – Juhana Aug 8 at 15:25 I currently have a User Model and a Post Model. The Post Model is above, and there is no mention of the Post Model in the User Model so far.

I just want to be able to get access to User. First_name and User. Last_name from within "app/views/posts/index.

Ctp – DJDonaL3000 Aug 8 at 15:34.

You don't have to do anything, a Child is also a Post, so also belongsTo a User. (And you should name it "Child" not "Children") With containable, try this: $this->Post->find('all',array('contain'=>array('Child'=>array('User')))).

Ok, thank you. But the DEBUG() is still only showing the User data for the Posts, and not for the children of each post.? Sorry about this;) – DJDonaL3000 Aug 8 at 19:23 Child does not seem to be regarded as a Post. Thanks for your help;) – DJDonaL3000 Aug 8 at 22:05 "what's the output if you call debug($this->Post->Child); " -> added above... – DJDonaL3000 Aug 9 at 15:17 I see there's a User object in your Child object.

Just make sure you have containable enabled and some correct data in the DB. – Anh Pham Aug 9 at 19:20.

You put it in the Children model. By the way, what you posted is the model, not the controller. Hopefully it's just a typo and you have that in the correct place.

It's also unclear if you call the model "Child" or "Children". The $hasMany relationship is uses Children, but in the question you say Posts. Child -- do you have the inflection set up correctly?

EDIT: I may have misunderstood the question: if you want a hasMany relationship, you already have that. The problem is either in the way you retrieve the data or in the relationship definition.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions