title: How do I use fetchAll in php?
body: <p>I am using this statement to fetch the elements in a column in my db</p>
  
  <pre><code>$result = $stmt-&gt;fetchAll(PDO::FETCH_COLUMN, 0);
  </code></pre>
  
  <p>but I get this error when trying to run it.</p>
  
  <p>Call to undefined method <code>mysqli_stmt::fetchAll();</code></p>
  
  <p>Is there something I need to add to my php file to include that method or something?</p>
  
  <p>UPDATE 1:</p>
  
  <pre><code>class LoginAPI
  {
  private $db;
  
  function __construct() 
  {
      $this-&gt;db = new mysqli('xxx', 'xxx', 'xxx', 'xxx');
      $this-&gt;db-&gt;autocommit(FALSE);
  }
  
  function __destruct() 
  {
      $this-&gt;db-&gt;close();
  }
  
  function login() 
  {
      if(isset($_POST["lang"]))
      {
          $stmt = $this-&gt;db-&gt;prepare("SELECT code FROM locations");
          $stmt-&gt;execute();
          $stmt-&gt;bind_result($code);
  
          //while($stmt-&gt;fetch())
          //{
          //  result[] = "code"=&gt;$code;
          //  break;
          //}
          $codeArr = array();
          $result = $stmt-&gt;fetch_all();//|PDO::FETCH_GROUP;
  
  
  
  
          sendResponse(200, json_encode($result));
          return true;
      }
      sendResponse(400, 'Invalid Request');
      return false;
  }
  }
  </code></pre>