Friday, December 31, 2010

Re: URGENT - Help needed - Model Association

Thanks @cricket and @John

@John I generated the code and then added the relationships manually .
Tried all from scratch ..and now it associates well and correctly :)

@Cricket will try both now

Thanks for the help

Karthik

On Fri, Dec 31, 2010 at 4:15 AM, John L <confidential99@gmail.com> wrote:
Since we both trust the generated code why don't you do the associations using the bake command also? Much simpler.

I only mention the incorrect names as these were the names indicated in the first message. It matters. 


On Thu, Dec 30, 2010 at 12:03 AM, Karthikeyan P <pkaarthikeyan@gmail.com> wrote:
John

  I think the class name conventions are correct as the code is a generated one ..I didn't write the code.It was generated by "cake bake" command .


" Model 'Comment' has a 'comments' table, not a 'Comments'
table. "


I have not defined anywhere as Comments Table..I have done as comments only

I guess the problem is in the relationship type during the model association ? Not sure though

Thanks
Karthikeyan P


On Thu, Dec 30, 2010 at 4:08 AM, john lyles <confidential99@gmail.com> wrote:
If the model names are Post and User then the table names should be
'posts' and 'users' lowercased. The field name is 'user_id' not
'UserId'. Model 'Comment' has a 'comments' table, not a 'Comments'
table. You have to respect CakePHP's File and Classname conventions,
see section 2.4.1 in the manual.

On Dec 29, 11:19 am, pinastro <pkaarthike...@gmail.com> wrote:
> I have created a Blog Application using a base table as 'Posts'. Later
> Model-Associated with another table 'Users' with 'belongsTo'
> relationship like below in the MODEL
>
> var $belongsTo = array(
> 'User' => array(
> 'className' => 'User',
> 'foreignKey' => 'user_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> )
> );
>
> But still I am not able to store the UserId in the Posts Table ???
> What's the Problem
>
> Plus what does the following lines of code mean :: I saw the
> comments_controller.php which got generated using the BAKE command
> when MODEL ASSOCIATED the 'Posts' table with the 'Comments' Table :
>
> $posts = $this->Comment->Post->find('list');
> $this->set(compact('posts'));
>
> If not above ; is there anyway I can store the UserId in the Posts
> Table using Model Associated cakePHP application ?

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+unsubscribe@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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: