Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Database Transaction Issue.
  • Hi together.
    I try to start a database transaction on configuration seems fine but when i execute something like:
    Edit: slightly edited the code.
    $result = array();
     $query = (Array) $query;
     
     try {
         \DB::start_transaction();
         foreach ($query as $subquery) {
    
      $result[] = \DB::query($subquery)->execute();
         }
         \DB::commit_transaction();
         return $result;
     } catch (Exception $ex) {
         \DB::rollback_transaction();
         throw $ex;
     }
    
    I get the error Message:
    ErrorException [ Error ]: Call to a member function beginTransaction() on a non-object
    
    in:
    COREPATH/classes/database/pdo/connection.php @ line 217
    

    Thats where the beginTransaction gets called on $this->_connection.
    If i uncomment the escape call, the code Works, so it seems like the instance is not created otherwise. I tried to debug the corresponding code, but was not able to find the exact problem. Does anyone know whats going on here? Thank you in advance.
  • I solved the problem by adding the following line to the core (see above, line 217):
        $this->_connection or $this->connect();
    
    I added a ticket on github and they already fixed it in the core.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion