Skip to content
Advertisement

Sqlite PDO query returns no results

Getting no results no matter how broad my query PHP: 5.3 Sqlite3: 3.6 PDO: 5.3.3 I would think this should be a very simple process but even looking around I still don’t know why I’m getting 0 results. Here is my code:

JavaScript

Any ideas on what I am doing wrong? The ‘foo’ table will only have four columns, and this test db only has one table. Running the query in sqlite displays the results fine.

Advertisement

Answer

You have to execute the statement first than fetch the result.

You might add try/catch block around the execute method call. and do some error handling.

Here’s an example of catching an Exception. Do not use it as a design guideline.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement