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