Reputation: 1103
What is my problem is I using php version 5.4 will have this error in MY_Controllar, kindly take a look the screenshot as below
but there are not problem below php version 5.3
here is my code
<?php
class MY_Controller extends CI_Controller {
function __construct()
{
parent::__construct();
$data->the_leave_data = $this->leave_data(); <--- line 8 is here
$this->the_leave_data = $data->the_leave_data;
$this->load->vars($data);
}
function leave_data()
{
$data = array();
$this->load->model('leave_data_model');
$staff_id = $this->session->userdata('staff_id');
if($query = $this->leave_data_model->get_by('staff_id',$staff_id))
{
$data['leave_data_records'] = $query;
}
var_dump($data);
return $data;
}
}
?>
here is the var_dump return value from $data
leave_data_records' =>
object(stdClass)[21]
public 'leave_data_id' => string '1' (length=1)
public 'staff_id' => string '1' (length=1)
public 'annual_leave' => string '1.0' (length=3)
public 'sick_leave' => string '0.0' (length=3)
public 'annual_leave_balance' => string '0.0' (length=3)
public 'sick_leave_balance' => string '0.0' (length=3)
public 'year' => string '2012' (length=4)
Any Idea how to solve it? Thanks
Upvotes: 2
Views: 2953
Reputation: 66
are you using PHP 5.4? PHP 5.4 has strict standards. You need to declare $data as an object of stdClass:
$data = new stdClass();
$data->the_leave_data = $this->leave_data();
Upvotes: 5
Reputation: 7688
Means that $this->leave_data();
is empty.
I don't see no where, to be loaded with data inside your controller. If you define it somewhere else end it's loaded from within CI_Controller
... you should do parent::$this->leave_data();
Upvotes: 0