0

I created dynamic menu with Dynamic_menu.php library. Inside file I use active record

$query = $this->ci->db->get($table);

for calling table, but when I change $query to

$this->ci->db->select('*');
$this->ci->db->from('menu_master_new_copy');
$this->ci->db->where('parent_id', 0);
$query = $this->ci->db->get();

I get error:

Undefined offset

How to fix it ?

pirho
  • 11,565
  • 12
  • 43
  • 70
  • 1
    parent_id should not be 0 – saddam Jan 29 '18 at 09:21
  • but before i try in sql SELECT * FROM `menu_master_new_copy` WHERE parent_id='0'; and this work, or when i change 0 to be 1 or any in codeigniter, query still error Undefined offset – Frans Chaniago Jan 29 '18 at 09:25
  • 1
    Undefined offset means that you're trying to access an array index that doesn't exist. This error is likely being displayed due to whatever you're doing with the results. – IsThisJavascript Jan 29 '18 at 09:25
  • 2
    post the line where you are getting this error and how you are accessing the data – Jigar Shah Jan 29 '18 at 09:28
  • Is that the complete error message you are getting? Just "Undefined Offset" all on it's own ? – TimBrownlaw Jan 29 '18 at 09:32
  • Ok so you can check SQL Statements... What does echo $this->ci->db->last_query(); after your "get" give you... That is the generated SQL. So try that out and see what result that gives you. Only asking to show how to start debugging. – TimBrownlaw Jan 29 '18 at 09:35
  • Have you try to not use `$this->ci->db->select('*');` ? The query should already return all columns if no name are specified – Kobi Jan 29 '18 at 10:06

0 Answers0