Dear support,
i propose a change for the page admin_pc_add_2.
When you insert/update something in the DB, to see if a record already exist you do a select and then an update (for example):
[quote]SELECT MAX(shares_timestamp) FROM shares WHERE shares_uuid = '77FBB0BA-F5B2-D511-B0D5-001083FDFE8A' SELECT count(shares_uuid) AS count FROM shares WHERE shares_uuid = '77FBB0BA-F5B2-D511-B0D5-001083FDFE8A' AND shares_caption = 'IPC remoto' AND shares_name = 'IPC$' AND shares_path = '' AND (shares_timestamp = '20060827130004' OR shares_timestamp = '20060828115126')
[color=red]Count: 1[/color]
UPDATE shares SET shares_timestamp = '20060828115126' [color=red]WHERE shares_name = 'IPC$' AND shares_uuid = '77FBB0BA-F5B2-D511-B0D5-001083FDFE8A' AND shares_timestamp = '20060827130004'[/color] I think that , in some cases, it could generate errors, sometimes "count" is not 1 but more... (see other thread in the forum, services and software duplicated). If you remove the count statement and simply intorduce a mysql_num_rows, you will obtain the same effect, but then you can use an update using the record ID found by the previous select. Like this: [quote]SELECT (shares_uuid) AS count FROM shares WHERE shares_uuid = '77FBB0BA-F5B2-D511-B0D5-001083FDFE8A' AND shares_caption = 'IPC remoto' AND shares_name = 'IPC$' AND shares_path = '' AND (shares_timestamp = '20060827130004' OR shares_timestamp = '20060828115126')
[color=red]mysql_num_rows : XXX[/color]
UPDATE shares SET shares_timestamp = '20060828115126' [color=red]WHERE id_share='_id_found_before_'[/color]
I think it's more correct, also under the coding's point of view.
Another thing...
Sometimes admin_pc_add_2, to discover if a record already exists, uses a select and then an update (case above), sometimes it uses an update, then it checks for the affected rows and then, if affected rows=0, it does an insert.
Why you do not use always the same procedure, select and insert or update?
Thanks, bye!
_________________ [color=blue]Lorenz[/color]
|