So far, you have seen a few simple examples that showed the basics of how Oracle transactions work in PHP. This section takes you through more complex examples of using transactions in PHP/Oracle applications.
As you learned from the examples discussed earlier in this chapter, the oci_execute
function allows you to execute an SQL statement in one of two modes—OCI_COMMIT_ON_SUCCESS mode and OCI_DEFAULT
mode.
While statements are automatically committed when run in the OCI_COMMIT_ON_SUCCESS
mode, you have to explicitly call oci_commit
or oci_rollback
to commit or roll back the transaction respectively, when specifying the OCI_DEFAULT
mode.
However, it is interesting to note that a transaction created when a statement is executed in the OCI_DEFAULT
mode may still be committed without calling oci_commit
. To accomplish this, all you need to do is to execute a subsequent statement in the OCI_COMMIT_ON_SUCCESS
mode.
The above technique...