Date: 09/30/98
- Next message: Darrell Brogdon: "RE: [PHP3] Suggestions for improvement"
- Previous message: Zeev Suraski: "Re: [PHP3] Suggestions for improvement"
- Next in thread: Brown, Patrick: "[PHP3] RE: How to handle transactions?"
- Maybe reply: Brown, Patrick: "[PHP3] RE: How to handle transactions?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wednesday, September 30, 1998 8:37 PM, Brown, Patrick
[SMTP:pbrown <email protected>] wrote:
> Can anyone tell how to handle transactions in my scripts? I have a
script that makes a database connection, then makes insert or update
queries, and then closes the connection. I am unsure how to add this
functionality to my system.
>
> I am using running PHP on NT 4, IIS 4, ODBC 3.x, and MSSQL 6.5.
Since I'm about to do some MS SQL and PHP stuff in the near feature your
message
got my attention. I checked out some old ASP scripts I wrote a long time
ago, in which
I used transactions with MS SQL. The basic of a transaction is simple. You
probably have seen this before:
1) you begin the transaction (odbc_????)
2) you execute all updates / deletes / inserts (odbc_exec)
3) you check for any failure
4) you commit the transaction or you roll it back. (odbc_commit /
odbc_rollback)
"odbc_commit" and "odbc_rollback" are documented but I couldn't find any
odbc equivalent for "MyConn.BeginTrans". (ASP)
"odbc_prepare" is close but doesn't mention anything about transactions.
I've included a piece of ASP code , which I actually found on the PHP
example site http://php.netvision.net.il
when I was searching for "transaction". How odd to find ASP code when
searching a PHP example site :)
The example below is quite clear and can easily be translated into PHP-code
when
someone would tell us how to do a "odbc_begintrans".
==========
<%
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "FILEDSN=C:\Program Files\Common Files\ODBC\Data
Sources\JupiterData.dsn"
MyConn.BeginTrans
MyConn.Execute("UPDATE YourAccount SET Balance=Balance+100 WHERE
Account='1'")
MyConn.Execute("UPDATE MyAccount SET Balance=Balance-100 WHERE
Account='1'")
MyConn.CommitTrans
MyConn.Close
%>
==========
Just my $0.02.
Kind regards,
Walter
======================================
email : walter <email protected>
Tentacle Interactive : http://www.tentacle.nl
Framework Executive : http://www.framework.nl
- application/ms-tnef attachment: stored
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3
- Next message: Darrell Brogdon: "RE: [PHP3] Suggestions for improvement"
- Previous message: Zeev Suraski: "Re: [PHP3] Suggestions for improvement"
- Next in thread: Brown, Patrick: "[PHP3] RE: How to handle transactions?"
- Maybe reply: Brown, Patrick: "[PHP3] RE: How to handle transactions?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

