Uploaded image for project: 'Doctrine DBAL'
  1. Doctrine DBAL
  2. DBAL-202

Preparing Statements outside Transaction


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Drivers
    • Security Level: All
    • Labels:


      From the mailing list:

      I'm using DBAL 2.1 with Oracle and it appears that if I call prepare() for my SQL and cache the prepared statement for later, if I then start a new transaction and call execute() on the statement, it commits the transaction. Is this behavior intentional? If so, does that mean I have to prepare my statement anew for every transaction?

      Note that I'm seeing the aforementioned behavior with code as basic as the following:

      $stmt = $dbh->prepare("INSERT INTO test_table (id, description) VALUES
      (:my_id, :my_desc)");
      $stmt->execute(array(":my_id" => 1, ":my_desc" => "test"));

      After executing the above, a record has been committed to the db. If I had a more complex scenario involving a transaction with multiple statements where the entire transaction is inside a loop, this becomes problematic--I can't then prepare my statements outside the loop to improve performance.

      When I try the same thing using straight PDO, it works fine. Can anyone else confirm this behavior?



          • Assignee:
            beberlei Benjamin Eberlei
            beberlei Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: