首頁 >後端開發 >php教程 >為什麼使用'prepare”、'bind_param”、'bind_result”和'fetch”後'mysqli_stmt::num_rows”始終回傳零?

為什麼使用'prepare”、'bind_param”、'bind_result”和'fetch”後'mysqli_stmt::num_rows”始終回傳零?

DDD
DDD原創
2024-12-08 05:43:09302瀏覽

Why Does `mysqli_stmt::num_rows` Consistently Return Zero After Using `prepare`, `bind_param`, `bind_result`, and `fetch`?

mysqli num_rows 總是回傳零

問題:

答案:

MySQLi 呼叫的錯誤使用。若要解決此問題,請在取得行數之前執行下列步驟:

呼叫 store_result() 對於 mysqli_stmt::num_rows 正常運作至關重要。

$stmt->execute();
$stmt->store_result();
這裡是修改後的程式碼片段,新增了 store_result() 呼叫:

請參閱有關更多詳細信息,請參閱 mysqli_stmt::num_rows 的官方文檔。

以上是為什麼使用'prepare”、'bind_param”、'bind_result”和'fetch”後'mysqli_stmt::num_rows”始終回傳零?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn