473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to deal with several users using php at once

348 100+
Hi all..

Didn't expect to be back so soon but I have an other dilema going on where I can sure use some expert advice.

I have a php system that will be used in a multi-user environment. There is one screen that concerns me with regard to records that are sitting there waiting to be worked with.

If there are say, 3 records on the screen and 3 users using the application. What happens to the data (MySQL) if two users grab the same record.

I'm sure I have to use transactions to protect the data but is that enough? Will a transaction throw an error to the screen in a windoze environment to let the user know that the record is locked? I would like the user, through php to be alerted to the fact that someone has already grabbed the record and is working with it.

I was thinking that instead of the user chosing a record to work with, I could just use the session somehow to *assign* the record to an available person. Not quite sure if that is doable or an easy fix.

Can somebody please advise or share your experiences.

Man, I am hoping that there is an easy solution for me on this.

Thanks!

Frank
Aug 21 '07 #1
6 1226
pbmods
5,821 Expert 4TB
Heya, Frank.

MySQL is very good about queueing queries. Especially if you are using transactions, MySQL will require any query that modifies any table in that transaction to wait until the current transaction is committed or rolled back.

'out-of-the-box', you should be good to go.
Aug 21 '07 #2
jx2
228 100+
well trasaction are oki but mysql_connect() close the connection at the end of the script - iam not sure if mysql_pconnect() does the job (i didnt try)

what i did in one of the projects ,were many people write and updates many articles, i added to extra columns "lock_it" and "unlock_time"
i did that cos i wanted others to see the article all the time but if someone chose it to update it was clearly shown that someone is changing it right now.


unlock_time - user have one hour to update if he failed the lock_it=0
(some people picked staff and never did updates)

of course YMMV

regards
jx2
Aug 21 '07 #3
fjm
348 100+
Heya, Frank.

MySQL is very good about queueing queries. Especially if you are using transactions, MySQL will require any query that modifies any table in that transaction to wait until the current transaction is committed or rolled back.

'out-of-the-box', you should be good to go.
Hey there Pbmods,

Ok, that is good to know that I should be good to go with transactions. I have yet to use them for anything so I will have to read up on them to find out a little more about exactly what thay can do for me.

I am wondering.... If two users open the same record for updating (User1 and User2) at the same time, I understand that the record will lock. Thats cool..

But what happens to User2's update data info once user1 finishes the update? Is it just discarded? or will the transaction then overwrite what User1 has done.

Thanks

Frank
Aug 21 '07 #4
fjm
348 100+
well trasaction are oki but mysql_connect() close the connection at the end of the script - iam not sure if mysql_pconnect() does the job (i didnt try)

what i did in one of the projects ,were many people write and updates many articles, i added to extra columns "lock_it" and "unlock_time"
i did that cos i wanted others to see the article all the time but if someone chose it to update it was clearly shown that someone is changing it right now.


unlock_time - user have one hour to update if he failed the lock_it=0
(some people picked staff and never did updates)

of course YMMV

regards
jx2
Jx2,

Thank you for that suggestion. I may be able to implement something like that to let the users know that the record is being modified. I'm not sure if maybe I should use the users session_id and lock the record for just that user for a certain amount of time, or what.. Certainley something I can ponder while I am in the bathroom. :)

If you have any additional suggestions, please feel free to post them..
Aug 21 '07 #5
pbmods
5,821 Expert 4TB
Heya, Frank.

MySQL isn't multi-threaded; it will run one query at a time. So if you are doing everything in a single transaction, you'll be fine.

If you needed to execute multiple queries and/or transactions per connection, then you might benefit from using the LOCK TABLES command at the start of the script, and then the UNLOCK TABLES command at the end.
Aug 21 '07 #6
fjm
348 100+
Heya, Frank.

MySQL isn't multi-threaded; it will run one query at a time. So if you are doing everything in a single transaction, you'll be fine.

If you needed to execute multiple queries and/or transactions per connection, then you might benefit from using the LOCK TABLES command at the start of the script, and then the UNLOCK TABLES command at the end.
Hey Pbmods.. Thanks for that! I appriciate that link as I think I will probably have to go multi-threaded but it doesn't seem bad at all. :)
Aug 21 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: hourman | last post by:
We have a web site IIS 5 (on Win2000k) with Oracle 9i backend (Sun unix). There is 1 user ID to oracle(APT_W3) that is used by all users (50). We have a global.asa file that has one APP Start...
8
by: Tom Siltwater | last post by:
building variable width/DB tables etc using getrows instead of movenext. Performance is a major concern as this app requires SSL. My question is, when does it become more about the challenge of...
1
by: mary | last post by:
I am developing an Access db which will be used by multiple users. My questions are: Does MS Access have problems with multiple users accessing the db at once? If yes, what is your solution...
1
by: Davy | last post by:
My program deal with a several level tree with several branchs. The amount of branchs from father node is not known. So I want to creat a tree with dynamic branchs. Now I use the structure:...
2
by: matthias | last post by:
I am creating a database which is supposed to contain many data entries (events) that differ only in the date they occur. So let's say event 1 occurs every Monday, Tuesday and Sunday between...
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
9
by: JJ | last post by:
I have a need to add several userid's (for example) to a table in an sql database. The usernames will all added to a listbox (or similar) and a 'submit' button will be clicked to send them to the...
8
by: Nick | last post by:
Hi there, Membership.GetNumberOfUsersOnline() works great the first time, then jumps up to the number of users registered in the system. I have tried enumerating through each user individually...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.