Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 260929FA1DB for ; Mon, 6 Nov 2006 15:47:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 28463-09 for ; Mon, 6 Nov 2006 15:47:45 -0400 (AST) X-Greylist: delayed 00:30:17.778847 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6AF939FA333 for ; Mon, 6 Nov 2006 15:47:45 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from tetra.ehpg.net (tetra2.ehpg.net [65.19.161.8]) by svr4.postgresql.org (Postfix) with ESMTP id 4DD345AF2CB for ; Mon, 6 Nov 2006 19:17:26 +0000 (GMT) Received: from gmr-dev.glyphix.com ([74.62.32.120] helo=[192.168.1.30]) by tetra.ehpg.net with esmtpa (Exim 4.62) (envelope-from ) id 1Gh9yF-0002pU-5x; Mon, 06 Nov 2006 11:17:23 -0800 In-Reply-To: <200611061105.29055@hal.medialogik.com> References: <20061026181147.50048.qmail@web51309.mail.yahoo.com> <200611061105.29055@hal.medialogik.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-php@postgresql.org Content-Transfer-Encoding: 7bit From: "Gavin M. Roy" Subject: Re: PostgreSQL locking from PHP scripts Date: Mon, 6 Nov 2006 11:16:51 -0800 To: Alan Hodgson X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/10 X-Sequence-Number: 3628 Well you can use persistent connections. Instead of pg_connect use pg_pconnect. I don't know if it will keep the lock or not, I've not tested, but it seems like you'd need a pretty elaborate connection management setup to make sure you're locking and unlocking the records for the right client. On Nov 6, 2006, at 11:05 AM, Alan Hodgson wrote: > On Thursday 26 October 2006 11:11, Amal burman > wrote: >> postgresql database for this project. Here script one >> (booking.php) tries to setup a lock for update and ask >> user to fill-up the form. Now when the user fill-up >> the form and submit it for update, second script >> (update.php) update the database and releasing the >> locks. > > You can't do this kind of thing in PHP. PHP resets the database > connection > between scripts. The script is finished as soon as the page is > delivered > to the client. > > Also, web connections are stateless and there is no way to even > know what > web server process or database connection you'll be getting on > subsequent > page views. > > -- > "It is a besetting vice of democracies to substitute public opinion > for > law." - James Fenimore Cooper >