title: Delete function not working within a transaction pdo php mysql
body: <p>I am having similar problems as this colleague: <a href="https://stackoverflow.com/questions/11790402/pdo-refuses-to-delete-a-row-of-data-in-specific-table">similar problem</a></p>
  
  <p>I am surprised that a Delete function within a transaction with pdo does not behave properly. If I use the delete function alone in a pdo it works perfectly but when I combine the delete function with an update function in a transaction it stops working (only first query works). I have tried all the answer and tips from the old thread but nothing seems to work. Can someone help me here?</p>
  
  <p>The code that I am working with:</p>
  
  <pre><code>function denyactionevent(){
  
  
          try {
              $$this-&gt;setAttribute(PDO::ATTR_AUTOCOMMIT, true);
              $$this-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
               $this-&gt;conn-&gt;beginTransaction();
  
          // product update query
          $query = "UPDATE 
                      " . $this-&gt;table_name . " 
                  SET 
                      accepted = :accepted 
  
                  WHERE
                      id = :id";
  
          // prepare query statement
          $stmt = $this-&gt;conn-&gt;prepare($query);
  
          // bind variable values
          $stmt-&gt;bindParam(':accepted', $this-&gt;accepted);
          $stmt-&gt;bindParam(':id', $this-&gt;id);
  
          // execute the query
          $stmt-&gt;execute();
  
          $query2 = "DELETE  
                     FROM event_case 
                     WHERE reference = :id
                  ";
  
          // prepare query statement
          $stmt = $this-&gt;conn-&gt;prepare($query2);
  
          // bind values
          $stmt-&gt;bindParam(':id', $this-&gt;id);
  
  
      // execute the query
          $stmt-&gt;execute();   
  
  
      $this-&gt;conn-&gt;commit();
      return true;
  
  
  
  } catch (Exception $e) {
    $stmt-&gt;rollBack();
    return false;
  }
      }   
  </code></pre>