I have this foreach loop:
$d=$dbh->prepare("SELECT * FROM users_rented WHERE since <= unix_timestamp(CURRENT_TIMESTAMP - INTERVAL 14 day) AND clicks_last <= unix_timestamp(CURRENT_TIMESTAMP - INTERVAL 14 day)");
$d->execute();
$array = array();
foreach ($d as $data ) {
$array[] = $data['id'];
#print_r($new_array);
$userToRecycleFor = $data['user_by'];
$outcome = $rentedrefs->_recycleMulti(0, $userToRecycleFor, $array, 1);
}
The $d query has 2406 results when I run it in the MySQL database.
The foreach loop is only being run 1 time on every page refresh. So instead of updating all 2406 users (as per the SQL query), it updates only 1 per refresh.
What am I doing wrong?
PDO::fetchphp.net/manual/en/pdostatement.fetch.php