amal.barman Posted October 26, 2006 Share Posted October 26, 2006 Hello,I am unable to solve a locking problem. I am usingpostgresql database for this project. Here script one(booking.php) tries to setup a lock for update and askuser to fill-up the form. Now when the user fill-upthe form and submit it for update, second script(update.php) update the database and releasing thelocks. This is working for client (say) A and B frompsql prompts but failed from PHP scripts. I havewritten following scripts as follows.booking.php-----------...$db=pg_pconnect($host,$database); // PostgreSQL database$sql_str="BEGIN; SELECT * FROM seat WHERE seat_no=1FOR UPDATE NOWAIT";...<FORM method="get" action="update.php">// collecting user's input...update.php----------...$db=pg_pconnect($host,$database); $sql_str="UPDATE seat SET status='booked' WHEREseat_no=1; END";...// endMy update script failed to do lock the table andrecords. How can I fix? One WARNING is showing byPostgreSQL, "there is no tranaction in progress". Thanks for your help in advance. ??? Quote Link to comment https://forums.phpfreaks.com/topic/25224-database-locking-problem-from-php-scripts/ Share on other sites More sharing options...
btherl Posted October 27, 2006 Share Posted October 27, 2006 I don't think pconnect allows you to keep transactions between HTTP requests.Instead, you can do application level locking. Create an entry in a table, and have other competing processes also create the same entry. If there's a conflict, one process will fail. Once the entry is successfully created, that represents an exclusive lock for the process which created the table entry. That'll work as long as all processes which may alter that table respect the application level locking mechanism.How were you planning to end the transaction if the client never fills in the form? Quote Link to comment https://forums.phpfreaks.com/topic/25224-database-locking-problem-from-php-scripts/#findComment-115183 Share on other sites More sharing options...
amal.barman Posted October 27, 2006 Author Share Posted October 27, 2006 Thanks btherl for your response. Quote Link to comment https://forums.phpfreaks.com/topic/25224-database-locking-problem-from-php-scripts/#findComment-115458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.