Okay, I have been tearing my hair (and beard) out at this one for a good hour or more now. I can't work out why it isn't working, particularly as it's exactly the same code I use elsewhere which does work.
$sql = "SELECT * FROM `aio_log` ORDER BY `log_timestamp` DESC LIMIT 10;"; // A 'WHERE' will be put in here
$logs = array();
$one_log = array();
if ($stmt = $mysqli->prepare($sql)) {
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($one_log['id'], $one_log['timestamp'], $one_log['headline'],
$one_log['text'], $one_log['link'], $one_log['font_awesome'],
$one_log['type']);
while ($stmt->fetch()) {
if ($one_log['link'] == "") $one_log['link'] = '#';
// print_r($one_log); shows the expected output of the database row.
$logs[] = $one_log;
//array_push($logs, $one_log); // gives the same - incorrect - response as the above line
}
}
print_r($logs); // Shows the right number of returned rows from the database, but all showing
// an identical content of the last database row returned.
Probably the only difference between this code and code I've used elsewhere is that this one doesn't have any binded parts of the SQL statement as it's a simple 'select everything no matter what' statement, but as the print_r($one_log)
bit works fine, I cannot see this being the issue. The issue is obviously somewhere in the $logs[] = $one_log
bit, but as I've used it elsewhere, and get exactly the same result using array_push
, I'm at my wits end here!
Ideas folks?