控制器:
function active_event() {
$this->load->view('active_event');
$a = $this->load->model('Usermodel');
}
型号:
function active() {
$query = $this->db->query(" SELECT * from event WHERE start > FORMAT(Now(),'MM-DD-YYYY') AND end < FORMAT(Now(),'MM-DD-YYYY')");
foreach($query->result_array() as $row){
$image = $row['image'];
$mobile = $row['mobile'];
$email = $row['email'];
$country = $row['country'];
$id = $row['id'];
$this->session->set_flashdata('id', $id);
}
$data = array('name' => 'name',
'image' => 'image',
'mobile' => 'mobile',
'email' =>'email',
'country' =>'country',
'id'=> 'id'
);
return $data;
}
答案 0 :(得分:0)
您需要使用在模型中创建的函数,然后以这种方式将其传递给视图:
function active_event() {
//Load model
$this->load->model('Usermodel');
//Call model function and save it to $data['a']
$data['a'] = $this->usermodel->active();
//Pass the $data array to the view - in the view you will be able to use $a
$this->load->view('active_event', $data);
}