I have the following code.
class IQTCulturaBD{
protected $mysqli;
const LOCALHOST = 'localhost';
const USER = 'xxxx';
const PASSWORD = 'xxxxxxx';
const DATABASE = 'fffff';
/**
* Constructor de clase
*/
public function __construct() {
try{
//conexion a base de datos
$this->mysqli = new mysqli(self::LOCALHOST, self::USER, self::PASSWORD, self::DATABASE);
}catch (mysqli_sql_exception $e){
//Si no se puede realizar la conexion
http_response_code(500);
exit;
}
}
public function geElemento($id=0){
$stmt = $this->mysqli->prepare("SELECT * FROM elemento WHERE id=?");
$stmt->bind_param('s', $id);
$stmt->execute();
$result = $stmt->get_result();
$elemento = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
return $elemento;
}
public function getElementos(){
$sql = "SELECT id,nombre,encabezado,latitud,longitud FROM elemento";
$result = $this->mysqli->query($sql);
$elementos = $result->fetch_all(MYSQLI_ASSOC);
$result->close();
return $elementos;
}
}
but the function $ elements = $ result-> fetch_all (MYSQLI_ASSOC); It does not work for me, it does not give me an error either, the PHP version is 5.5.12