I often get problems with mysql queries that are malformed in the codebase I'm working on. Unfortunately, the error that gets passed back is usually very unhelpful:
Mysql error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':status0 OR FlagStatus = :status1 ) ORDER BY OrderId DESC, GiftCardId DESC' at line 1]
Because I'm frequently using a dynamically generated query, and don't know what the original query looked like when it went in (unlike when I'm using the command line), so the errors often start just after the information that would actually be useful.
So... ...is there some way for me to get the last query that was used, so that I can display the full query after the mysql error is thrown?