/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Modification(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Modification'])) { $model->attributes = $_POST['Modification']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
protected function saveChar($model) { if (!($brand = Brand::model()->find('alias=:alias', array(':alias' => $model->brand_alias)))) { $brand = new Brand(); } $brand->title = $model->brand; $brand->alias = $model->brand_alias; $brand->save(); if (!empty($brand->errors)) { d('brand ' . $brand->title); d($brand->errors); } if (!($car = Car::model()->find('alias=:alias', array(':alias' => $model->model_alias)))) { $car = new Car(); } $car->brand_id = $brand->id; $car->title = $model->model; $car->alias = $model->model_alias; $car->manufacture_start = $model->modificationManufactureStart . '0101'; $car->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null; $car->save(); if (!empty($car->errors)) { d('model ' . $car->title); d($car->errors); } if (!($mod = Modification::model()->find('alias=:alias', array(':alias' => $model->mod_alias)))) { $mod = new Modification(); } $mod->model_id = $car->id; $mod->title = $model->mod; $mod->alias = $model->mod_alias; $mod->manufacture_start = $model->modificationManufactureStart . '0101'; $mod->manufacture_end = $model->modificationManufactureEnd ? $model->modificationManufactureEnd . '0101' : null; $mod->save(); if (!empty($mod->errors)) { d('mod ' . $mod->title); d($mod->errors); } if (!($char = Characteristic::model()->find('modification_id=:mod_id', array(':mod_id' => $mod->id)))) { $char = new Characteristic(); } $char->attributes = $model->char->attributes; $char->modification_id = $mod->id; $char->save(); if (!empty($char->errors)) { d('char ' . $mod->title); d($char->errors); d($model->url); } }
static function logMerge(Doctrine_Record $r) { $mod = new Modification(); $mod->object_model = get_class($r); $mod->object_id = $r->id; $mod->object_name = $r->getName(); $mod->user_id = LsVersionableListener::getUserId(); $mod->is_merge = true; $mod->save(); }