問題描述
我有一個像這樣執行的復雜查詢:
I have a complex query that gets executed like this:
if ($stmt = $dbi->prepare($pt_query)) {
$stmt->bind_param('ssssssssi', $snome,$scognome,$ssocieta,$svia,$slocalita,$sprovincia,$scap,$stelefono,$sfax,$uid);
$stmt->execute();
echo $dbi->error;
$stmt->close();
} else {
printf("Error -> %s
", $dbi->error);
}
這件事失敗了,沒有任何錯誤,它根本沒有更新數據庫.由于在此之前有大量數據需要處理,我想知道是否有任何方法可以顯示 mysqli 正在執行的實際查詢,以便了解問題出在哪里.
This thing is failing without any error, it simply doesn't update the database. Since there is a ton of data that gets treated before this thing I would like to know if there is any way to show the actual query that mysqli is executing in order to understand where the problem is.
謝謝.
推薦答案
如果你的語句失敗,你應該檢查 $stmt->error
(而不是 $dbi->錯誤
).至于獲取查詢的實際文本:這是不可能的.使用準備好的語句時,庫使用了一種特殊協議,該協議不會為每個 ->execute()
調用生成實際的查詢字符串.
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.
這篇關于有沒有辦法打印 mysqli->execute() 所做的實際查詢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!