Hi,
i have this project about fighters.
i add a match between 2 fighters and beforeSave() i get fighter’s rank and points, save the match and afterSave() i take the result and calculate points, i write them in ranking table. after this i query the table and order by points DESC and loop through result and add to the same table the rank.
first i don’t know what is the best procedure to do it faster
second is that i want a popup after all these operations ends with a report that tells me if everything went ok or not and the reason why.
i tried this:
$transaction=$connection->beginTransaction();
try
{
$connection->createCommand($sql1)->execute();
$connection->createCommand($sql2)->execute();
//.... other SQL executions
$transaction->commit();
}
catch(Exception $e)
{
$transaction->rollback();
}
i made some errors on purpose and indeed rolledback BUT only on operations after the match saves because they run afterSave() and it also did not show me any errors/report. i probably don’t know how to do it.
any idea to make this possible ?
thank you