Tuesday, 15 February 2011

mysql - joined UPDATE/INSERT in CI active records -



mysql - joined UPDATE/INSERT in CI active records -

i saw on office mate can update using joins? question can codeigniter's active record? given next sql query:

update tbl1 bring together tbl2 on tbl1.id = tbl2.tbl1_id set tbl1.column2 = "value1", tbl2.column3 = "value1" tbl1.column1 = 1;

lastly, there specific version of mysql need utilize me execute this? thanks!

mysql version >3.23 supports joined-table update statements. can ci:

$this->db->set('tbl1.column2', 'value1'); $this->db->set('tbl2.column3', 'value2'); $this->db->where('tbl1.column1', 1); $this->db->update('tbl1 bring together tbl2 on tbl1.id = tbl2.tbl1_id');

mysql sql codeigniter activerecord codeigniter-2

No comments:

Post a Comment