If your statement is failing, you should check $stmt->error
(as opposed to $dbi->error
). As far as getting the actual text of the query: it’s not possible. When using prepared statements, the library is using a special protocol that doesn’t generate an actual query string for each ->execute()
call.