0

This is functions not working is correct:

function primaryParent($id)
{
    $result = $this->querySingle('select parentid from menu where id = ' . $id . ' limit 1');
    if ($result) 
        $result = $this->primaryParent($result);
    else 
        return $result;
}

What is my error?

This function must return primary parent id, not first parent.

In database items group by parrentid field, and then show:

  • Primary menu item
    • Submenu item 1
    • Submenu item 2
      • Sub submenu item 1
      • Sub submenu item 2
      • Sub submenu item 3
    • Submenu item 3

I need get primary menu item id from sub submenu item.

I use SQLite3 functions.

Octoloper
  • 205
  • 2
  • 9

1 Answers1

1

Your function is not returning anything for the if ($result) case.
You probably want return $this->primaryParent($result);.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Sure, but if I use ```return $this->primaryParent($result);``` in ```if ($result)``` case I see this error: ```AH00052: child pid 23153 exit signal Segmentation fault (11)``` and Nginx show ```502 Bad Gateway``` – Octoloper Mar 25 '14 at 14:06
  • That's pretty damn uncommon and has apparently uncovered some bug in the underlying PHP code. – deceze Mar 25 '14 at 14:16