This PDO prepared statement returns false but does not throw an error

后端 未结 6 1711
[愿得一人]
[愿得一人] 2021-02-18 23:09

This code does not throw an error but the query fails, that is, the execute method returns false. How could that be?

require_once(\"Abstracts/DBMana         


        
6条回答
  •  不思量自难忘°
    2021-02-18 23:40

    I'm pretty sure that MySQL chokes on the desc field name - it is a reserved word. You'd have to put it into "`" quotes or, better, change the field name.

    As for error reporting, use the errorInfo method. You can make PDO actually output the result of a failed query in the exception, but the default behaviour - I think - is to throw an exception only if the query can't be made at all, but it doesn't fail if the query is faulty.

提交回复
热议问题