public function actionCreate() { $model = new Topics(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
$vals = $_POST['newstopic']; if (isset($_POST['id'])) { $id = intval($_POST['id']); } if (!empty($_FILES['pic']['name'])) { $attachment->rename_file = "newstopic-" . $time_stamp; $attachment->insert_new = false; $attachment->if_watermark = false; $attachment->upload_process(); $vals['picture'] = $attachment->file_full_url; } if (!empty($id)) { $vals['modified'] = $time_stamp; $pdb->Execute("DELETE FROM {$tb_prefix}topicnews WHERE topic_id=" . $id); $topic->addNews($id, $_POST['data']['news']); $result = $topic->save($vals, "update", $id); } else { $vals['created'] = $vals['modified'] = $time_stamp; $result = $topic->save($vals); $key = $topic->table_name . "_id"; $topic->addNews($topic->{$key}, $_POST['data']['news']); } if (!$result) { flash(); } else { flash("success"); } } if (isset($_GET['do'])) { $do = trim($_GET['do']); if (!empty($_GET['id'])) {