By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,723 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,723 IT Pros & Developers. It's quick & easy.

Query and Synchronization...

P: n/a
Hi people!
I was writing a function in which I execute a query to READ some
value, and another one to UPDATE the previous query related data.

i.e.
query-select * from ..... to retrieve myvalue
read myvalue
change myvalue
query-update myvalue

Suddenly I had a doubt...
Can 2 or more browsers call the same function at "same time" and start
the UPDATE query with some still uncomputed data? or is the function
synchronized?
In positive case, should I use some mechanism as Semaphore?
tnx in advance, Giovanni

Apr 25 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rik
Giovanni wrote:
Hi people!
I was writing a function in which I execute a query to READ some
value, and another one to UPDATE the previous query related data.

i.e.
query-select * from ..... to retrieve myvalue
read myvalue
change myvalue
query-update myvalue

Suddenly I had a doubt...
Can 2 or more browsers call the same function at "same time" and start
the UPDATE query with some still uncomputed data? or is the function
synchronized?
Well, 'uncomputed data', no... They can overwrite each others changes
though. Most of my systems aren't that busy, so I opt for:
UPDATE table SET field1=..., field2=... WHERE field1=..., field2=...

If there's no row updated, report the record has been changed, and ask
the user again...

--
Rik Wasmus

Estimated date being able to walk again: 01-05-2007.
Less then a week, hurray!
Apr 25 '07 #2

P: n/a
That's the situation... I've to grant round robin algho in a small
number of records i.e. 20...
The operations are theese:
MYSQL->select id,ticket
PHP-search ticket=true
MYSQL-SET ticket=false with id=ID
MYSQL-SET ticket=true with id=nextticket_at_id();

semaphore could help me?

I was thinking to change strategy...
I wisha use datetime type to retrieve the oldest record not retrieved,
and so update it with NOW()
selecting the record in age order and limiting to 1 i could have what
I want...
dont'you think?

Apr 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.