我一直在尝试通过控制器函数将一些变量传递给模型,以便可以在数据库中的相应查询中使用该变量。这是我的代码
public function chooseGroup()
{
$data['area']=$_GET['area']; //variable from a view source;this is loaded successfully in this function, i have printed an echo to be sure.
$this->load->model('information_model',$data);
$groupdata['rows']= $this->information_model->getGroupDetails();
// var_dump($groupdata);
}
型号代码:
function getGroupDeatils() {
$this->db->select('area'); //area is suppose to contain the value
$q = $this->db->get('group'); //group is the table name
if ($q->num_rows() > 0)
foreach ($q->result() as $rows) {
$data[] = $rows;
}
return $data;
}
由于某种原因,值 $data['area'] 未被信息模型识别,因此未处理查询。我哪里出错了?:(请帮忙!