0
我从模型传递一个参数,以查看这样get_where()是否允许多个参数?
模型
class school_model extends CI_Model{
function employee_get($student_id){
$query = $this->db->get_where('students', array('student_id'=>$student_id));
return $query->row_array();
}
}
控制器
function bret($student_id){
$this->load->model('school_model');
$data = $this->school_model->employee_get($student_id);
echo $data['student_gender'];
}
这显然转换为给定的例如和通过浏览器等http://example.com/env/at/index.php/frontpage/bret/306
select * from students where id=id
我想知道get_where()
是否合适如果我想有这个疑问
select student_gender,student_has_a_medical_condition from students where (student_gender = 'female' && student_has_a_medical_condition = 'no') LIMIT 40;
我将需要延长get_where()
为它工作?
我希望找到诸如'http:// example.com/env/at/index.php/frontpage/bret/female/no /'这样的网址,可以使用提取'uri'来完成,但只能使用参数吗?我希望你明白我在说什么。 –
那么你可以在''frontpage''控制器'bret'方法中添加可选参数:'bret($ student_id,$ gender = null,$ condition = null)',然后在空测试后将这些参数传递给你的模型。或者你问你是否可以从模型中检测这些URI段并将其用作条件? – Wolf
是的,这就是我问的问题。 –