Ok, well in my controller, before I pass anything I print_r my
variable, and the output looks like this:
Array (
[0] => Array (
[Section] => Array (
[id] => 1 [name] => topnav )
[Menu] => Array (
[0] => Array (
[id] => 1 [name] => Home [path] => / )
[1] => Array (
[id] => 1 [name] => Home [path] => / )
)
)
)
It does look rather skew-wiff to me. Here is my model:
class Section extends AppModel {
var $name = 'Section';
var $hasAndBelongsToMany = array(
'Menu' => array('className' => 'Menu',
'joinTable' => 'menus_sections',
'foreignKey' => 'section_id',
'associationForeignKey' =>
'section_id',
),
);
}
So my Section model has a id and a name. Menu model has a id, name
and path, and the join table (menus_sections) has a menu_id and
section_id.
On 3/20/07, f. <[EMAIL PROTECTED]> wrote:
>
> > foreach($menus['Section']['Menu'] as $menu) {
>
> Hi,
>
> it' hard to read code in the google layout... especially pr()
> output...;)
> looks like the array is numeric...
> try:
> foreach($menus as $menu) {
> echo $menu['Section']['id'];
> pr($menu['Menu']);
> ...
> }
>
> greets,
>
> f.
>
>
>
> Array (
> [0] => Array (
> [Section] => Array (
> [id] => 1
> [name] => topnav
> )
> [Menu] => Array (
> [0] => Array (
> [id] => 1
> [name] => Home
> [path] => /
> )
> [1] => Array (
> [id] => 2
> [name] => News
> [path] => /posts/
> )
> )
> )
> )
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---