As long as you have var $belongsTo = array('Author'); in your Comment
model, just set recursive to a higher value.

$this->Post->recursive = 2;
$posts = $this->Post->findAll();

Cheers,
Adam

On May 3, 3:40 am, deeps <[EMAIL PROTECTED]> wrote:
> Ok, i m trying cakephp for one of my application, till now no errors
> are there & cakephp is making life easy....
>
> but now i am stuck in one simple problem
>
> I am having these tables in database
>
> Post
> -id (PK)
> -title
> -description
>
> Comment
> -id (PK)
> -comment
> -post_id (FK)
> -author_id (FK)
>
> Author
> -id (PK)
> -name
> -email
> -website
>
> Now Post will have many comments & each comment will have One author
>
> Now in post if i write
> <?php
> var $name =  'Post';
> var $hasMany = array('Comment' =>  array('className'    => 'Comment',
>                                                  'conditions'   => '',
>                                                  'order'        => '',
>                                                  'limit'        => '',
>                                                  'foreignKey'   =>
> 'post_id',
>                                                  'dependent'    =>
> true,
>                                                  'exclusive'    =>
> false,
>                                                  'finderQuery'  => '',
>                                                  'fields'       => '',
>                                                  'offset'       => '',
>                                                  'counterQuery' =>
> ''));
> ?>
>
> i will get
>
> Array ( [0] => Array ( [Post] => Array ( [id] => 1 [title] => xyz
> [description] => xyz ) [Comment] => Array ( [id] => 1 [comment] => xyz
> [post_id] => 1 [author_id] => 1 )
>
> What i want is instead of having author id in this particular result,
> i want to show up author name with built in functionality of cakephp
> or any shortcut method of cake instead of writing any custom query.??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to