title: Transactions in codeigniter with multiple tables
body: <p>I'm new to transactions in general, but especially with CodeIgniter.  I'm using InnoDB and everything, but my transactions aren't rolling back when I want them to.  Here's my code (slightly simplified).</p>
  
  <pre><code>            $dog_db = $this-&gt;load-&gt;database('dog', true);
              $dog_db-&gt;trans_begin();
  
              $dog_id = $this-&gt;dogs-&gt;insert($new_dog); //Gets primary key of insert
              if(!$dog_id)
              {
                  $dog_db-&gt;trans_rollback();
                  throw new Exception('We have had an error trying to add this dog.  Please go back and try again.');
              }
  
              $new_review['dog_id'] = $dog_id;
              $new_review['user_id'] = $user_id;
              $new_review['date_added'] = time();
  
              if(!$this-&gt;reviews-&gt;insert($new_review)) //If the insert fails
              {
                  $dog_db-&gt;trans_rollback();
                  throw new Exception('We have had an error trying to add this dog.  Please go back and try again.');
              }
  
                  //ADD DESCRIPTION
              $new_description['description'] = $add_dog['description'];
              $new_description['dog_id'] = $dog_id;
              $new_description['user_id'] = $user_id;
              $new_description['date_added'] = time();
  
              if(!$this-&gt;descriptions-&gt;insert($new_description))
              {
                  $dog_db-&gt;trans_rollback();
                  throw new Exception('We have had an error trying to add this dog.  Please go back and try again.');
              }
  
                  $dog_db-&gt;trans_rollback();  //THIS IS JUST TO SEE IF IT WORKS
                  throw new Exception('We have had an error trying to add this dog.  Please go back and try again.');
  
              $dog_db-&gt;trans_commit();
  }
  
  catch(Exception $e)
  {
      echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>I'm not getting any error messages, but it's not rolling back either.  It should roll back at that final trans_rollback right before the commit.  My models are all on the "dog" database, so I think that the transaction would carry into the models' functions.  Maybe you just can't use models like this.  Any help would be greatly appreciated!  Thanks!</p>