title: PHP : PDO fetch() not showing result
body: <p>I'm now learning PDO I just followed the tutorial on Youtube. So here I have here a method from Db class and I added a new line PDO::FETCH_ASSOC because I want to try a while loop besides of foreach.</p>
  
  <pre><code>public function query($sql, $params = array()){
  $this-&gt;_error = false;
  $this-&gt;_count = 0;
  if($this-&gt;_query = $this-&gt;_pdo-&gt;prepare($sql)){
  
    #check if theres a parameter and bindvalue to sql statement
    if(count($params)){
      $x = 1;
      foreach($params as $param){
        $this-&gt;_query-&gt;bindValue($x, $param);
        $x++;
      }
    }
  
    #execute with or without parameter
    if($this-&gt;_query-&gt;execute()){
      $this-&gt;_results = $this-&gt;_query-&gt;fetchAll(PDO::FETCH_OBJ);
      $this-&gt;_whileFetch = $this-&gt;_query-&gt;fetch(PDO::FETCH_ASSOC);
      $this-&gt;_count = $this-&gt;_query-&gt;rowCount();
    }else{
      $this-&gt;_error = true;
    }
    return $this;
  }
  } #end of GET function
  
  
  public function whileFetch(){
     return $this-&gt;_whileFetch;
  }
  </code></pre>
  
  <p>The foreach is working well, but I want to try a while loop but it seems not working, not showing any data.</p>
  
  <pre><code>$query = $db-&gt;query("SELECT * from master_data.store");
  while($row = $query-&gt;whileFetch()){
       echo $row['name'];
  }
  </code></pre>
  
  <p>I also try this, but i got error.</p>
  
  <pre><code>while($row = $query-&gt;fetch(PDO::FETCH_ASSOC)){
      echo $row['name'];
  }
  </code></pre>