I am actually using this to store and know some fields of my database:
$conn_2 = dbConnect();
$stmt2 = $conn_2->prepare("SELECT firstname, lastname, type FROM BrokerMaster.users WHERE email = ?");
$stmt2->bind_param("s", $email);
$stmt2->execute();
$stmt2->bind_result($firstname, $lastname, $type);
while ($stmt2->fetch()) {
printf("%s %s %s\n", $firstname, $lastname, $type);
}
But I would like to do something like:
$stmt2 = $conn_2->prepare("SELECT * FROM BrokerMaster.users WHERE email = ?");
$stmt2->bind_param("s", $email);
$stmt2->execute();
$stmt2->bind_result($result); //??
while ($row = $stmt2->fetch()) {
$firstname = $row["firstname"]
}
I couldn't find a way to do it object oriented. The problem I found is that the $result
is not a mysqli_result
class (if I am not wrong) and unlike query()
the execute()
and bind_results()
don't create it. (I also couldn't manage to use this answer
What are my mistakes (or misunderstandings)? How can I do it?