I am trying with this code to fetch all data but its not work.
my code for database connection
function initializeConnection(){
$host = "localhost";
$username = "xxx";
$password = "xxx";
$dbName = "xxx";
$mysqli = new mysqli($host, $username, $password, $dbName);
if (mysqli_connect_errno()) {
die('Could not connect: ' . mysqli_connect_error());
}
return $mysqli;
}
my code for dfetch data
function getResultFetchAll($sql){
global $mysqli;
$mysqli = initializeConnection();
$result = $mysqli->query($sql);
return $mysqli->fetch_all(MYSQLI_ASSOC);
}
Error showing
PHP Fatal error: Uncaught Error: Call to undefined method mysqli_result::fetch_all()