I am trying to store an array of fetched data into a session, with the code below, but when i try to execute it, the execution time exceeds 30 seconds and it fails. I can't seem to spot the error, so i'm hoping for a helping hand.
public function stat_query($user_id = null)
{
$query = $this->core->conn->query("SELECT user_stats.value as value, stats.shortname as shortname FROM user_stats INNER JOIN stats ON user_stats.stat_id = stats.id WHERE user_stats.user_id = ".$this->get_user($user_id));
$value = $query->fetch(PDO::FETCH_ASSOC);
return $value;
}
public function init_stat_array($user_id = null){
while($query = $this->stat_query($this->get_user($user_id))) {
$this->temp_array[$query['shortname']] = $query['value'];
}
}
public function store_session($user_id = null) {
$this->init_stat_array($this->get_user($user_id));
$_SESSION['stats'] = $this->temp_array;
}
Note: the the get_user function works as intended, it just returns the user that was bound in the constructor, or the inputted user.