> $conn = OCIPLogon("scott", "tiger", "testdb");

> $statement = OCIparse($conn, "INSERT INTO Dummy VALUES ('A')");
> OCIexecute($statement, OCI_DEFAULT);
>
> $statement = OCIparse($conn, "INSERT INTO Dummy VALUES ('B')");
> OCIexecute($statement, OCI_DEFAULT);
>

> $statement = OCIparse($conn, "INSERT INTO Dummy VALUES ('C')");
> OCIexecute($statement, OCI_DEFAULT);

> OCICommit($conn);



Sapporo wrote:
Hi,

I'm trying to avoid excessive database connections within my app.

From the docs, I figured that the following code would insert 2 rows of data into table Dummy, since the connection would be reused and the transactions aren't isolated by using OCINLogon() (error handling left out for readability):

$conn = OCIPLogon("scott", "tiger", "testdb");
$statement = OCIparse($conn, "INSERT INTO Dummy VALUES ('A')");
OCIexecute($statement, OCI_DEFAULT);

$conn = OCIPLogon("scott", "tiger", "testdb");
$statement = OCIparse($conn, "INSERT INTO Dummy VALUES ('B')");
OCIexecute($statement, OCI_DEFAULT);

OCICommit($conn);

But it turns out that only the second row gets written to the database. So, what difference would it make to use OCINLogon()? Is this the expected behaviour?

How does everyone else handle this? Is it possible to store database connections in a session?

TIA,
-sapporo.

BTW, I'm using PHP 4.3 on Linux talking to Oracle9i.



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to