0

Fatal error: Call to a member function fetchAll() on a non-object in **************/includes/Dbo.class.inc on line 41

Line 41:

public function selectCondition($database, $table, $condition, $condition_value){
  return $database->debug()->select($table, "*", array($condition => $condition_value))->fetchAll(PDO::FETCH_ASSOC);
}

After calling this function to get an result array it displays the error mentioned above. Any ideas?

Thamilhan
  • 13,040
  • 5
  • 37
  • 59

1 Answers1

0

According to documentation select() returns array so you can't call any other method on this result.

So your code should look like this:

return $database->debug()->select($table, "*", array($condition => $condition_value));

edit:
It is not working also because of debug mode. Correct code should look like this:

 return $database->select($table, "*", array($condition => $condition_value));
nospor
  • 4,190
  • 1
  • 16
  • 25
  • After removing the function fetchAll();var_dump returns a boolean(false).. –  May 20 '16 at 13:10
  • So you have db error. Try `var_dump($database->error());` to see what happened. – nospor May 20 '16 at 13:12
  • result from var_dump($database->error()) ´array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL }´ –  May 20 '16 at 13:18
  • Try this `$zm = $database->debug()->select($table, "*", array($condition => $condition_value));` `var_dump($zm);` `var_dump($database->error());` `return $zm;` – nospor May 20 '16 at 13:24
  • result: SELECT * FROM "auftraege" WHERE "idauftrag" = '1'bool(false) array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL } –  May 20 '16 at 13:27
  • Ah, I see in code, that in debug mode query is not executed at all... Just remove `->debug()` – nospor May 20 '16 at 13:48
  • Thank you very much! It works! –  May 20 '16 at 14:34