Hellow everyone.
I have the following code:
if(isset($_GET['uchid']) && isset($_GET['pid']))
{
$pred = $_GET['pid'];
$uchen = Uchni::model()->findByPk($_GET['uchid']);
$predmet = Predmety::model()->find("uchen_id=:uchen_id and $pred = 1",array(':uchen_id'=>$_GET['uchid']));
if($uchen && $predmet)
{
$uchen->delete();
$predmet->delete();
}
}
It’s very important for my application that when $uchen is deleted $predmet is deleted as well, otherwise my app will crash. How can I make sure that records from both tables are deleted simultaniously?
Is it possible to use transaction here?