I ran into a problem with CodeIgniter when trying to call an object from data stored in a session.
Code:
public function do_index_1 ()
{
$tags= $this->input->post('tags');
$data['recommendation_for_you_unlimited']=$this->db->query
("SELECT *, MATCH(tags, message) AGAINST ('$tags') as score
FROM game
WHERE MATCH(tags, message) AGAINST ('$tags')
ORDER BY score
");
$data['recommendation_num'] = $this->db->get('game')->num_rows();
$this->session->set_userdata($data);
}
public function do_index_3 ()
{
$data['recommendation_num'] = $this->session->userdata('recommendation_num');
$data['recommendation_for_you_unlimited'] = $this->session->userdata('recommendation_for_you_unlimited');
}
The data is stored into the session variable in do_index_1 and pulled to show in do_index_3. The first variable $data['recommendation_num'] is output fine, but the second $data['recommendation_for_you_unlimited'] triggers the error:
The script tried to execute a method or access a property of an incomplete object.
I have searched here and there and found that it might be because $data['recommendation_for_you_unlimited'] is an object. But I'm not sure how to fix it.