php - How do I insert into database with codeigniter without it putting the single quotes? -
i'm making feature in app users can select multiple db items , change department belong @ once. have in codeigniter model currently:
function multimove($dept, $jobstring) { $sql = "update jobs set department = ? id in(?)"; $this->db->query($sql, array($jobstring, $dept)); echo $this->db->last_query(); }
the function takes in 2 values department number , id's of selected jobs. i'm trying achieve sql function:
update jobs set department = 3 id in(5,6,48);
but codeigniter generates this:
update jobs set department = '3' id in('5,6,48');
it puts single quotes on values , creates errors. there way around this?
calling model
$this->load->model('model_jobs'); $this->model_jobs->multimove(3,'2,3,8');
model
function multimove($dept,$jobstring) { $ids = explode(",",$jobstring); $upd_data = array('department' => $dept ); $this->db->where_in('id', $ids); $this->db->update('test', $upd_data); echo $this->db->last_query(); }
Comments
Post a Comment