0
節省一排排我有2個表結構如下:Yii的1 - 刪除其他表
Store(name, model, serial_number)
Work(name, model, serial_number, adress)
當我添加一條記錄表工作,我從表中存儲的數據獲取與計算ListData。問題是:如何在將Store保存到Work後將其從Store中刪除?
public function actionCreate()
{
$model=new Work;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Work']))
{
$model->attributes=$_POST['Work'];
if($model->save()) {
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('create',array(
'model'=>$model,
));
}
我試着寫querys在if($model->save)
塊,但我不知道如何serial_number
刪除行。
我想我應該使用交易,但我不知道如何在我的例子中使用它。
非常感謝!現在它運作良好。 –
很高興爲您效勞。 – hamed