/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = $this->loadModel($id); ItemValue::model()->deleteAll("company_id ='" . ${$model}->company_id . "' and year ='" . ${$model}->year . "'"); Yii::app()->db->createCommand("delete from tbl_general where id='" . $id . "'")->queryAll(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionGenerateLedgerGeneral() { if (isset($_REQUEST['General_company_name'])) { $company_id = $_POST["General_company_name"]; $year = $_POST["year"]; $ret = ItemValue::model()->deleteAll("company_id ='" . $company_id . "' and year ='" . $year . "'"); foreach ($_REQUEST as $key => $value) { if ($key == 'General_company_name' || $key == 'year') { continue; } if ($value != "") { $item = new ItemValue(); $it = explode('_', $key); $item->item_id = $it[1]; $item->value = $value; $item->company_id = $company_id; $item->year = $year; $item->save(); } } } }