本文介紹了PDO fetch 只返回第一行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我使用以下代碼連接數據庫,獲取Data_length
索引列,并根據數據計算數據庫大小.
I'm using the following code to make a connection to the database, fetch the Data_length
index column, and calculate the database size based on the data.
出于某種原因,PDO 將始終返回0",這是第一行中 Data_length
索引的值.無論我做什么,我都只得到第一行索引.
For some reason PDO will always return "0", which is the value for the Data_length
index in the first row. Whatever I do, I only get the first rows index.
數據庫為 MySQL,引擎為 MyISAM.
The database is MySQL, the engine MyISAM.
PHP 版本:5.5.38
MySQL 版本:5.5.50
PHP Version: 5.5.38
MySQL Version: 5.5.50
這是源代碼.
推薦答案
添加一個 while 循環,
Add a while loop,
或者你可以使用 fetchAll
這篇關于PDO fetch 只返回第一行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!