Welcome Guest, Not a member yet? Register   Sign In
Datamapper ORM 1.8.2 Need help with menu
#1

[eluser]Unknown[/eluser]
Hi everyone,

Categories
============
ID Name
-----------------
1 TV
-----------------
2 LED
-----------------
3 LCD
-----------------

Subcategories
============
id category_id subcategory_id
-----------------------------
1 1 2
-----------------------------
2 1 3

category_id is linked to ID of Categories and subcategory_id is linked to ID of Categories.

I've got all the relationships set and when I do something like the following:

Code:
foreach ( $categories as $cat )
{
    foreach ( $cat->subcategories->get() as $subcat )
    {
        echo $subcat->subcategory->get()->name . '<br/>';
    }
}

Output:

TV
TV

Even though the output should be more like this:

LED
LCD


I've gone completely code blind, I've been trying to figure this out for a few days now and it's driven me insane.

Thank you very much for any help.

Oh and if anymore info is required please let me know I'm more then happy to provide it.
#2

[eluser]WanWizard[/eluser]
Sounds like an error in defining your relations.




Theme © iAndrew 2016 - Forum software by © MyBB