public function actionV_copy($id) { $video = Video::model()->findByPk($id); $model = new Video(); //echo "<pre>"; //print_r($video->attributes); if (!empty($video->attributes)) { $data = $video->attributes; unset($data['id']); $data['title'] = $data['title'] . " -- Copy"; $model->attributes = $data; if ($model->save()) { $verlays = Overlays::model()->findAll("video_id = {$id}"); // print_r($verlays); foreach ($verlays as $overlay) { $newOv = new Overlays(); $data_ov = $overlay->attributes; unset($data_ov['id']); $data_ov['video_id'] = $model->id; $newOv->attributes = $data_ov; $newOv->save(); } } } //echo "</pre>"; // die(); $this->redirect(url("video/admin")); }
public function saveOverlay($post) { foreach ($post as $id => $arr) { if (is_numeric($id)) { $model = Overlays::model()->findByPk($id); $model->attributes = $arr; $model->save(); } } $arr = $post['new']; $model = new Overlays(); if (!empty($arr['url'])) { $model->attributes = $arr; if ($model->save()) { return new Overlays(); } } return $model; }