Welcome Guest, Not a member yet? Register   Sign In
What's the best way to determine if two tables were updated successfully using Active Record?
#1

[eluser]rvillalon[/eluser]
So it seems that Active Record doesn't currently support JOIN with UPDATE. So, I've had to resort to updating one table at a time. But is there a better way to structure this?

I have a function the returns a BOOLEAN if the update was successful or not. However, I can't determine if both tables were updated successfully, only the last one it seems.

Any thoughts?

Code:
function update_company_by_userid($user_id, $data)
{
    $data1 = array(
        'name' => $data['name'],
        'website_name' => $data['website_name'],
        'website_url' => $data['website_url'],
        'phone' => $data['phone'],
        'fax' => $data['fax']
    );

    $this->db->where('user_id', $user_id);
    $this->db->update($this->company_profiles_table_name, $data1);
    
    $data2 = array(
        'address1' => $data['address1']
    );

    $this->db->where('company_id', $this->_get_company_id($user_id));
    $this->db->update($this->company_address_table_name, $data2);
    
    if ( ! $this->db->affected_rows() || $this->db->affected_rows() > 0) return TRUE;
    return FALSE;
}


Messages In This Thread
What's the best way to determine if two tables were updated successfully using Active Record? - by El Forum - 08-05-2010, 11:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB