php - Using array as a condition in where clause codeigniter -
i have problems using array input value in where
clause.
but don't want utilize more 1 time in clause code.
in case, want :
$cond = array('job_id' => $job_id_var, 'job_name' => $job_name_var); //where clause $this->where($cond); //only using 1 time clause code this, array input //which means job_id = '$job_id_var' , job_name = '$job_name_var'
is possible in codeigniter?
yes, ->where()
method can back upwards that.
since do not want cascade it:
$this->db->where('job_id', $job_id_var); $this->db->where('job_name', $job_name_var);
->where()
can handle array input well:
$cond = array('job_id'=>$job_id_var, 'job_name'=>$job_name_var); $this->db->where($cond); // here, used once. $query = $this->db->get('hello_table'); $result = $query->result_array(); homecoming $result;
php codeigniter
No comments:
Post a Comment