Call to a member function fetch() on boolean [duplicate]

As per the PHP manual for PDO::query

PDO::query() returns a PDOStatement object, or FALSE on failure.

It looks like your query is failing (on line 33) and thus returning a BOOLEAN (false), likely because at that point in execution, PDO has not connected to a database that contains a table called article. In the connect() method I see that it tries to connect to a db called ‘generatordatabase’; ensure this connection is being made prior to calling createTable(), otherwise ensure that it contains a table called ‘article’.

I would recommend adding some more code examples, for instance the code that calls this class/method before the error is triggered.

Leave a Comment