[eluser]seanloving[/eluser]
[quote author="flaky" date="1263391209"]a fast example
Code:
$this->db->where('column', $data['column_name']);
$this->db->join('table', 'table.column=table1.column1');
$this->db->update('table2', $data);
[/quote]
Hi,
I'm trying to write a query that will update some columns in the 'customers' table, some other columns in the 'contacts' table, and some other columns in the 'organizations' table. The 'customers' table has columns for 'contact_id' and 'organization_id' where I store foreign keys to their respective tables.
Here is a truncated example
Code:
$this->db->set('contacts.firstname', $data['firstname']);
$this->db->set('organizations.organization_telephone', $data['organization_telephone']);
$this->db->set('customers.updated_by', $this->session->userdata['user_id']);
$this->db->join('organizations', 'customers.organization_id = organizations.organization_id');
$this->db->join('contacts', 'contacts.contact_id = customers.contact_id'); //added
$this->db->where('customers.customer_id', $data['customer_id']);
$this->db->update('contacts');
echo $this->db->last_query();exit;
I echo the generated SQL and I havn't been able to get the JOIN to work, or even to appear :down: .
Does anyone on this thread know what I'm doing wrong?
Thanks