PDO fetch returns only first row

后端 未结 1 666
挽巷
挽巷 2020-12-12 08:04

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.

<
相关标签:
1条回答
  • 2020-12-12 08:56

    Add a while loop,

    while($row= $sth->fetch( PDO::FETCH_ASSOC )){ 
       echo $row['your_field_name'];
    }
    

    Or you can use fetchAll

    $rows = $sth->fetchAll();
    print_r($rows);
    
    0 讨论(0)
提交回复
热议问题