Welcome Guest, Not a member yet? Register   Sign In
Updating Multiple Tables
#4

[eluser]Joseph Wensley[/eluser]
I don't think you could do this all in one query but something like this might work.

Code:
$this->db->query("UPDATE student_applicants SET `status` = 'enrolled' WHERE `applicant_id` = '$applicant_id'");
$this->db->query("INSERT INTO master_people SET `status` = 'status', `role` = 'role'");
$user_id = $this->db->insert_id()
$this->db->query("INSERT INTO dept_people (`dp_userid`,`fname`,`lname`) SELECT '$user_id',`fname`,`lname` FROM student_applicants WHERE `applicant_id` = '$applicant_id'");

If the user_id in master_people isn't an autoincrement then obviously you would set it to something and use that instead of the insert_id for the 2nd insert.


Messages In This Thread
Updating Multiple Tables - by El Forum - 11-04-2010, 10:47 AM
Updating Multiple Tables - by El Forum - 11-15-2010, 05:25 PM
Updating Multiple Tables - by El Forum - 11-15-2010, 05:32 PM
Updating Multiple Tables - by El Forum - 11-15-2010, 07:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB