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.

0

1 Answer 1

1

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

2
  • 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, 2014 at 14:06
  • That's pretty damn uncommon and has apparently uncovered some bug in the underlying PHP code.
    – deceze
    Mar 25, 2014 at 14:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.