HOME       >>       Programming

Concurrency Problem? update together in the same time


.hack//GU

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.


urtrivedi

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



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.