So my host doesn't have the mysqlnd driver installed for mysqli, so I'm unable to use the get_result()
function (and it's not an option to install the mysqlnd driver). What are the alternatives to the following queries so that I don't use get_result()
?
I know that I can use the following to get a single result from the database:
if ($stmt = $cxn->prepare("SELECT `count` FROM `numbers` WHERE `count_id` = ?")) {
$stmt->bind_param('i', $count_id);
$stmt->execute();
$stmt->bind_result($count);
$stmt->fetch();
$stmt->close();
}
But what if I have to select several results from the database, loop through each, and get another result?
if ($stmt = $cxn->prepare("SELECT `count` FROM `numbers` WHERE `number` = ?")) {
$stmt->bind_param('i', $number);
$stmt->execute();
$result = $stmt->get_result(); // uses get_result()
}
if ($result->num_rows) { // uses get_result()
while ($row = $result->fetch_assoc()) { // uses get_result()
if($stmt = $cxn->prepare("SELECT `value` FROM `values` WHERE `number` = ?")) {
$stmt->bind_param('i', $row['count']);
$stmt->execute();
$stmt->bind_result($value);
$stmt->fetch();
$stmt->close();
}
}
}
I can't use this because some of the statements require get_result()
which I'm unable to use.
What are my alternatives?