Jump to content
xisto Community
Sign in to follow this  

Concurrency Problem? update together in the same time

Recommended Posts

I have a problem in PHP.When more than one client update something in database, they won't work.so, how do I make out for it?example:at the same time, in real-time chatboard, 2 persons click CHAT, what can I do so that both of them actually chat?or at bidding website, when 2 persons bid at same time, how could I do that?thanks for answer.

Share this post

Link to post
Share on other sites

Actually You can build Transactions before update or inserting data into database. also don't work with out proper primary and foreign keys in you tables.
Try to use autogenerate option for primary keys.

I suppose you are using mysql database,
I dont know about mysql transactions, but I use oracle 10g.

If I have to execute set of 2 query in the manner that 2 should succeed or no query should execute.

$query1="some insert";$statement1 = oci_parse($connection, $query1);if ((oci_execute($statement1,OCI_DEFAULT))){[indent]	 $query2="some more insert";	 $statement2 = oci_parse($connection, $query2);	 if ((oci_execute($statement2,OCI_DEFAULT)))	[indent]		   oci_commit($connection));   [/indent]	 	 else[indent]			  oci_rollback($connection));  [/indent][/indent]}else{			  oci_rollback($connection))  ;}

You please specify what problem exactly you are facing. Why you feel that you data is not concurrent.

Notice from rvalkass:

Code needs to go inside Code BBTags.
List of BBCodes

Edited by rvalkass (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.