0

我有这个代码片段。我想将数据从一个表复制到另一个..请看我的代码,这不起作用。

谢谢

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();
}
4

1 回答 1

0

你的代码看起来不错。问题可能出在一线

$packageassignment->save();

将其更改为

if(!$packageassignment->save()){
  echo 'packageassignment save failed!';
  //other debugging code
}

然后看看它是否给出错误。或者替换为您喜欢的错误记录技术。

于 2012-12-09T23:51:32.887 回答