Hi!

It's nagging me that hasAndBelongsToMany-relations do not respond to
$recursive.
I've got a news script. One can comment on the news, the news are
fetched correctly and the comments (a HABTM-relationship from
news->comments and a belongsTo-relationship from comments->user) are in
a numeric array. nothing wrong so far.
But when it comes to rendering the comment's details, I've got to
access the details of the author, e.g. to print his name (it's stored
in the database for the comment, just in case a user might cancel his
account, so that the name's left - or for guest postings). But the
'Author' relation isn't available directly.
I changed News->recursive from 1 to 2 ('Author' appears for comments,
but without value) and then to 5 to check whether it's an issue of
depth, but the Author-field is always empty.

I didn't plan to have a comment controller (since
'/newsComments/write/NEWS_ID' doesn't look as good as
'/news/comment/NEWS_ID') but now I just created one to have a method
called 'getComment($id)' which I can call from the view with
requestAction()  to fetch full details for every comment. There, all
relations are filled in just fine.

Now I wonder why HABTM-data is stored directly in a numeric array;
isn't is possible to have something like

...
[NewsComments] => Array
(
    [0] => Array
        (
             [NewsComment] => Array
                 (....
                 )
             [Author] => Array
                 ( ....
                 )
        )
)
...


instead of

...
[NewsComments] => Array
(
    [0] => Array
        (
             [id] => 3
             [title] => asd
             ...
             [author_id] => 2
             [news_id] => 13
        )
)
...


a foreach-loop to iterate every comment is currently breaking the habit
of writing $array['ModelName']['attribute'], because it's more
$item['attribute'].
Can I change that? Somehow? Or am I supposed to fetch the comment's
details by myself (requestAction() call etc.)?

Some things in CAKE still seem strange to me :)
Well, thanks for your help in advance!

Greetings,
Christian Tietze


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to