1
I have a table in mysql database that has a field genre
with that amount:
[{"id": 2, "genre_name": "action"}, {"id": 1, "genre_name": "comedy"}]
and would like to display all lines containing the genre_name
with the value comedy
My code:
function genres(){
$genres = $this->pdo->connect()->query("SELECT * FROM movie WHERE JSON_SEARCH(genre, 'comedy', '$.genre_name') IS NOT NULL");
return $genres->fetchAll(PDO::FETCH_OBJ);
}
When I try to display the return of the values this error is displayed:
Fatal error: Uncaught Error: Call to a Member Function fetchAll() on Boolean in C: wamp64 www class Contents.php on line 322
Error: Call to a Member Function fetchAll() on Boolean in C: wamp64 www class Contents.php on line 322
Need to debug, see if the problem is in the code or if the query returned any error
– rray
Related: https://answall.com/a/376919/45810 although this question presented an error not related to a query-specific problem, but rather that it was applying a method in one value
boolean
(true
orfalse
), instead of the objectPDOStatement
, as the documentation suggests.– LipESprY