title: SQLSTATE[HY000]: General error on PDOStatement->fetchAll(2)
body: <p>Is there any wrong with my Code? I tried to display the result but return zero and instead title above occur or is there any way around on how to get this smoothly. Please let me know. Thanks</p>
  
  <pre><code>    $pdo = Database::connect();
      $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, 1);
      $sql = ("               SET @curRank1 = 0;
                              SET @curRank2 = 0;
                              SELECT
                                  D1.reading_date
                                  ,D1.consumer_id
                                  ,D1.readings AS previous
                                  ,D2.readings AS current
                                  ,(D2.readings - D1.readings) AS kwh_used
  
                              FROM 
                              (
                                  SELECT M1.*, @curRank1 := @curRank1 + 1 AS rank
                                  FROM consumption M1
                                  LEFT JOIN consumption M2
                                  ON Date(M1.reading_date) = Date(M2.reading_date)
                                  AND M1.reading_date &gt; M2.reading_date
                                  WHERE M2.reading_date IS NULL
                                ) D2
                              LEFT JOIN
                              (
                                  SELECT M1.*, @curRank2 := @curRank2 + 1 AS rank
                                  FROM consumption M1
                                  LEFT JOIN consumption M2
                                  ON Date(M1.reading_date) = Date(M2.reading_date)
                                  AND M1.reading_date &gt; M2.reading_date
                                  WHERE M2.reading_date IS NULL
                              ) D1
                              ON D2.rank = (D1.rank + 1)  
                              WHERE D1.reading_date IS NOT NULL
                              AND D1.consumer_id = :consumer_id");
      $q = $pdo-&gt;prepare($sql);
      $q-&gt;execute(array($id));
      $q-&gt;nextRowset();
      $data = $q-&gt;fetchAll(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p><strong>EDIT</strong>: SQLSTATE[HY000]: General error onPDOStatement->fetchAll(2)</p>