在笨

2017-06-27 35 views
0

多個參數搜索我想用兩個參數patient_id和電子郵件在笨

控制器

型號搜索

function search_patients($search) 
{ 
return $query = $this->db->get_where('patient', array('patient_id'=> $search))->result(); 
} 
+0

要使用AND or OR –

+0

不明確的信息。請詳細說明。 –

+0

OR 解釋:任何一個 –

回答

1

你應該綁定你那裏像這樣

$where = '(patient_id ="' . $search . '" or email = "' . $search . '")'; 

$this->db->select('*'); 
$this->db->from('patient'); 
$this->db->where($where); 
$query = $this->db->get(); 
$result = $query->result_array(); // this will return you array 
return $result; 
+0

你是偉大的! !非常感謝你....願上帝保佑你 –

+0

很高興幫助:) –