I do not have mysqlInd
then it does not work fetch_assoc
sample Fatal error: Call to undefined method mysqli_stmt :: fetch_assoc () ni get_result()
Following this solution I'm trying to store all the columns in the queried row in a session $_SESSION['usuario']
and then query column by column so $_SESSION['usuario']['email']
as imitating fetch_assoc
but they are stored as a single array they do not differentiate between the columns if they are all stored together
$email=(empty($_POST['email'])) ? NULL : $_POST['email'];
$pwd =(empty($_POST['password'])) ? NULL : $_POST['password'];
if ($email && $pwd && $conn){
$sql='SELECT * FROM Usuarios WHERE email=? AND password=?';
$stmt = $conn->prepare($sql);
if($stmt){
$stmt->bind_param("ss",$email,$pwd);
$stmt->execute();
$stmt->store_result();
$filas=$stmt->num_rows;
if($filas>0){
$arrDatos=$stmt->fetch_assoc();
$_SESSION['usuario']=$arrDatos;
header('Location: consola.php');
$stmt->close();
$conn->close();
}
else
{
echo "No se encontraron registros";
}
}
else
{
echo "Error en la consulta: ".$stmt->error;
}
}
else
{
echo "Falta alguno de los datos del POST o la conexión es nula";
}
function myGetResult( $Statement ) {
$RESULT = array();
$Statement->store_result();
for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
$Metadata = $Statement->result_metadata();
$PARAMS = array();
while ( $Field = $Metadata->fetch_field() ) {
$PARAMS[] = &$RESULT[ $i ][ $Field->name ];
}
call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
$Statement->fetch();
}
return $RESULT;
}
Any advice?