PDO::FETCH_ASSOC not fetching everything

后端 未结 1 918
日久生厌
日久生厌 2020-12-12 01:25

I have this function:

function get_following($user_id) {
 global $conn;
 $stmt = $conn->prepare(\"SELECT * FROM following WHERE `follower_id`=:user\");
 $         


        
1条回答
  •  感情败类
    2020-12-12 01:49

    $following will have to be an array of rows. You are actually only fetching the first row. Fetch it using PDOStatement::fetchAll(), like this:

    $following = $stmt->fetchAll(PDO::FETCH_ASSOC);
    

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