Is there any way to print the actual query that mysqli->execute() makes?

后端 未结 4 1711
暖寄归人
暖寄归人 2020-12-04 01:41

I have a complex query that gets executed like this:

if ($stmt = $dbi->prepare($pt_query)) {   
        $stmt->bind_param(\'ssssssssi\', $snome,$scogno         


        
相关标签:
4条回答
  • 2020-12-04 02:02

    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.

    0 讨论(0)
  • 2020-12-04 02:06

    You could turn on logging on the MySQL DB itself, ie. add a log=logfile line to my.ini.

    Refer to the MySQL documentation for more information if needed.

    0 讨论(0)
  • 2020-12-04 02:18

    Based on the PHP mysql website there is no actual way of doing it. But you may try this function as it gives you errors in your query.

    0 讨论(0)
  • 2020-12-04 02:19

    Here's a tool I found that may help MySQLi Prepare Statement checker

    0 讨论(0)
提交回复
热议问题