title: How to fetch all in assoc array from a prepared statement?
body: <p>I'm trying this code:</p>
  
  <pre><code>    if ($result = $this-&gt;mysqli-&gt;prepare("SELECT * FROM `mytable` WHERE `rows1`=?"))
      {
  
          $result-&gt;bind_param("i",$id);
          $result-&gt;execute();
          while ($data = $result-&gt;fetch_assoc())
          {
  
              $statistic[] = $data;
  
          }
  
          echo "&lt;pre&gt;";
          var_dump($statistic);
          echo "&lt;/pre&gt;";
      }
  </code></pre>
  
  <p>but it's throwing the following error</p>
  
  <blockquote>
    <p>[Fri Jun 15 12:13:11 2012] [error] [client 127.0.0.1] PHP Fatal error:
    Call to undefined method mysqli_stmt::fetch_assoc() in [myfile.php]</p>
  </blockquote>
  
  <p>And also I've tried:</p>
  
  <pre><code>if ($result = $this-&gt;mysqli-&gt;prepare("SELECT * FROM `mytable` WHERE `rows1`=?"))
      {
  
          $result-&gt;bind_param("i",$id);
          $rows = $result-&gt;execute();
          while ($data = $rows-&gt;fetch_assoc())
          {
  
              $statistic[] = $data;
  
          }
  
          echo "&lt;pre&gt;";
          var_dump($statistic);
          echo "&lt;/pre&gt;";
      }
  </code></pre>
  
  <p>that makes this: </p>
  
  <blockquote>
    <p>[Fri Jun 15 12:22:59 2012] [error] [client 127.0.0.1] PHP Fatal error:
    Call to a member function fetch_assoc() on a non-object in
    [myfile.php]</p>
  </blockquote>
  
  <p>What else I can do for getting result or what I doing wrong? I need the assoc array from DB looking like <code>$data[0]["id"] = 1</code></p>