Welcome Guest, Not a member yet? Register   Sign In
self-referencing relationship is not working using datamapper
#12

[eluser]johnmerlino[/eluser]
This does exactly what I want to happen:

Code:
$zones = $this->input->post('zones');

            foreach($zones as $z){
                switch($z){
                    case 'main':
                        $a = new Zone();
                        $a->where('name',$z)->get();
                        $subcategory->save($a);
                        break;
                    case 'panel':
                        $b = new Zone();
                        $b->where('name',$z)->get();
                        $subcategory->save($b);
                        break;
                }
            }

            $subcategory->save(
                array(
                'related_category' => $parent_category
                )
            );

But as you can see, it doesn't look nice that I have to call save three times. I'm sure there's a better way.

Thanks for response.


Messages In This Thread
self-referencing relationship is not working using datamapper - by El Forum - 04-11-2011, 09:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB