EDIT: i forgot to add i just upgraded to version 2.0.2. Maybe this has something to do with it?
I have two database connections on my project. I tried to use an isolated transaction in a function but it threw the error mentioned in the title ("there is no active transaction").
By the way, i did not have this problem before, but it might be due to the fact the last time i used this method there was no second connection.
I did this example intentionally simple and naive, the code is actually quite a bit longer and obviously does not involve cats.
<?php
try{
$transaction = $this->getDI()->getTransactions()->get();
$person = new \Person();
$person->setTransaction($transaction);
//do other code stuff
//....
if(!$person->save()){
$transaction->rollback('Human could not be saved');
//it will not think there is any active transaction at this point
//and will instead throw an error
}
$cat = new \Cat();
$cat->setTransaction($transaction);
$cat->setWhiskerLength(1000);
if(!$cat->save()){
$transaction->rollback('The kitty could not be saved');
//it will not think there is any active transaction at this point
//and will instead throw an error
}
$transaction->commit();
catch(Failed $e){
echo $e->getMessage();
}
Both database connections are set $di->setShared(connection name)
I have no clue how to solve this problem. It used to work well.
Any ideas? Thanks in advance