Date: 09/30/98
- Next message: Darrell Brogdon: "RE: [PHP3] Suggestions for improvement"
- Previous message: stock-pick <email protected>: "[PHP3] AD: Stock-Pick Discovers Media Goldmine!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I may have the transactions figured out. I had to turn on track_errors in
the php.ini file. Someone please let me know if I am doing this wrong. I
would hate to corruct my database.
$conn = <email protected>("$dsn", "$user", "$password");
odbc_autocommit($conn, "Off");
== insert some script here ==
if ($php_errormsg == "")
{
odbc_commit($conn);
echo "Database Commit\n";
}
else
{
odbc_rollback($conn);
echo "Database Rollback\n";
}
odbc_close($conn);
--Patrick Brown
> -----Original Message-----
> From: walter <email protected> [mailto:walter <email protected>]
> Sent: Wednesday, September 30, 1998 3:56 PM
> To: 'Brown, Patrick'; 'php3 <email protected>'
> Subject: RE: How to handle transactions?
>
> 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: stock-pick <email protected>: "[PHP3] AD: Stock-Pick Discovers Media Goldmine!!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

