Welcome Guest, Not a member yet? Register   Sign In
best practice: multiple updates
#1

[eluser]dmol[/eluser]
Hi all,
I'm looking for a way to keep track of which tables/fields in a DB need to be updated.
Lets say I have 6 tables sharing a common key($id) and there are also some duplicated fields. When I'm doing an update, I need to keep track of which tables to update and which fields. Is there a good way of doing this? my approach is as follows:

pseudo code:
1/Get a list of tables/fieldnames used in the query as follows:
$data['table_name']['fields'][] = $this->db->list_fields('mytable');
--repeat for each table queried.--

2/Process form
3compare existing field values to new values and store changes as $changes[$field_name] => $value
4/foreach $data['table_name] => $myfield
if exists ($changes[$myfield]) --> function to update db with args($id, $table, $field, $value)

Is there a 'stream-lined' way of doing search->update multiple tables? I find the above approach too cumbersome.
Thanks
Dave


Messages In This Thread
best practice: multiple updates - by El Forum - 05-06-2011, 05:23 AM
best practice: multiple updates - by El Forum - 05-06-2011, 05:35 AM
best practice: multiple updates - by El Forum - 05-06-2011, 06:06 AM
best practice: multiple updates - by El Forum - 05-06-2011, 07:04 AM
best practice: multiple updates - by El Forum - 05-06-2011, 07:30 AM
best practice: multiple updates - by El Forum - 05-06-2011, 07:54 AM
best practice: multiple updates - by El Forum - 05-06-2011, 08:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB