Hello,

Im very new to CakePHP and have just started to learn Model
Association. If I make any errors in the google group, please excuse
me this is my first time on any google group.

I have 2 databases:

-news_posts
    -id
    -title
    -body

-comments
    -id
    -body
    -newspost_id

Here are the AppModel classes associated with them:

// app/models/newspost.php
class NewsPost extends AppModel {
    var $name = 'NewsPost';
    var $hasMany = 'Comment';
}

// app/models/comment.php
class Comment extends AppModel {
    var $name = 'Comment';
}

The problem is when i call $this->NewsPost->find('all'); from a
controller that var $uses = 'NewsPost';, I get this array:

Array
(
    [0] => Array
        (
            [NewsPost] => Array
                (
                    [id] => 10
                    [Title] => Cool, This works! LOL
                    [Body] => Wow, this really works! OMG LOL OMG
EDITING WORKS FINE
                    [Time] => 1254685359
                )

        )

)

As you can see, there is no [Comment] array in the sub-array [0].

Here is the data for my tables:

news_posts:

   id   |         title       |        body       |
   10  |   News Title   |   News Body   |

comments:

   id   |            body          |       newspost_id       |
   1    |   Comment Body   |             10                |

Any help would be greatly appreciated.

Thanks.

--~--~---------~--~----~------------~-------~--~----~
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