Re: php/mysql question regarding editing related tables
William Gill wrote on 26/03/2008 15:33:
> I am working on a form for editing and updating mysql data in several
> related tables like person, phoneNumber,and e-mailAddress.
>
> I need to display data from all three in order to know what records I am
> editing, but I don't want to do updates on unchanged records (i.e. if
> only phoneNumber changes, no need to update the other two).
>
> simplistically I could do the following:
>
> 1 query all 3 tables
hope this means: one single request over joined tables
> 2 store data in hidden fields
> 3 display data
> 4 user edit
> 5 submit
> 6 compare original data to data in form fields to determine changes (or
> use hasChanged flags)
> 7 update accordingly
or update whatever changes.
the choice may depends on your server roles, it mysql & php run on the
same machine, php will have a persistant connexion to the base, in that
case you can let mysql decides (verifies) if update is actually needed.
if mysql server runs on a separate server and if the cost of request
forward is not null, check in php code if update(s) are required.
Sylvain.
|