Test if a query worked

My understanding is that this


returns true if the Query returns at least 1 result.
Is there an if statement I can use to see if t he query was successful (even if it returns 0 results)

Don’t wonder, set a variable to the result and use var_dump(…) to view the result :slight_smile:


Wrap var_dump around:

echo "<pre>";
echo "</pre>":

Linefeeds will be shown that makes the value easier to read.

I use a function Fred($val) which saves typing.

That was hard work formatting on a tablet :frowning:


Yes, but you don’t need it. Just leave your query alone.

->errorInfo() and set your PDO to throw an exception on failure.

It makes no sense to use both. Just set error mode to exception.

Besides, the question was a different one

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.