Re: URGENT - Help needed - Model Association

2010-12-31 Thread Karthikeyan P
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 confidentia...@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 
 pkaarthike...@gmail.comwrote:

 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 confidentia...@gmail.comwrote:

 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@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.comcake-php%2bunsubscr...@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.comcake-php%2bunsubscr...@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: URGENT - Help needed - Model Association

2010-12-30 Thread cricket
How are you including $user_id? There are more than one approache you can take:

echo $this-Form-hidden('Post.user_id', array('value' =
$this-Session-read('Auth.User.id')));

Or you can add it to the submitted data inside the controller:

if (!empty($this-data))
{
$this-data['Post']['user_id'] = $this-Auth-user('id');

On Thu, Dec 30, 2010 at 12:03 AM, Karthikeyan P pkaarthike...@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 confidentia...@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+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


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: URGENT - Help needed - Model Association

2010-12-30 Thread John L
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 pkaarthike...@gmail.comwrote:

 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 confidentia...@gmail.comwrote:

 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@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.comcake-php%2bunsubscr...@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: URGENT - Help needed - Model Association

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


Re: URGENT - Help needed - Model Association

2010-12-29 Thread Karthikeyan P
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 confidentia...@gmail.comwrote:

 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@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