我有这段代码。我想将数据从一个表复制到另一个表..plz看到我的代码这不起作用。
感谢
protected function afterSave()
//Copy data from Client to packageassignment ***
// assuming your you're in the Client model
//and Client has id,package_id,p_start_date
{
$packageassignment= new Packageassignment();
$packageassignment->user_id=$this->id;
$packageassignment->package_id=$this->package_id;
$packageassignment->package_start_date=$this->p_start_date;
$packageassignment->save();
return parent::afterSave();
}
答案 0 :(得分:0)
您的代码看起来很好。可能问题在于
$packageassignment->save();
将其更改为
if(!$packageassignment->save()){
echo 'packageassignment save failed!';
//other debugging code
}
然后查看是否出错。或者用您首选的错误记录技术替换。