Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Fri Mar 29, 2024 11:55 pm

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Optimizing...
PostPosted: Mon Aug 28, 2006 8:05 pm 
Offline
Newbie
User avatar

Joined: Wed Aug 16, 2006 9:06 am
Posts: 45
Location: Rome - Italy - Europe (GMT +2)
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]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group