Reputation: 283
I am working on fetching data from a table in PHP with the following code. How can I copy all rows directly into an array? I tried fetch_array()
instead of fetch()
but it was also not successful.
$stmt = $this->db->prepare($sql);
$stmt->execute();
$stmt->bind_result($aID, $sID);
while ($stmt -> fetch()) {
echo $aID . " ". $sID . "<br>";
}
Upvotes: 0
Views: 2154
Reputation: 5524
If using PDO
the Fetch_column
is what you are looking for
$stmt = $this->db->prepare($sql);
$stmt->execute();
$stmt->bind_result($aID, $sID);
$Arrays = $stmt ->fetchAll(PDO::FETCH_COLUMN);
Upvotes: 1
Reputation: 73031
How can I copy all rows directly into array?
mysqli_fetch_all()
Upvotes: 0