/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model=new Orderperson; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Orderperson'])) { $model->attributes=$_POST['Orderperson']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'model'=>$model, )); }
public function updateOrderPeopleFor($model, $person_id, $type) { $rtn = false; $order_id = $model->id; $condition = 'order_id=' . $order_id; $condition .= ' AND LCASE(type) = "' . strtolower($type) . '"'; $criteria = new CDbCriteria; $criteria->condition = $condition; $result = Orderperson::model()->findAll( $criteria ); if(count($result)>0) { if(strtolower($type) === strtolower(Helper::CONST_Created)) return true; $record = $result[0]; } else { $record = new Orderperson; } if(empty($person_id) && !empty($record->id)) { $rtn = $record->delete(); } else { $record->order_id = $order_id; $record->person_id = $person_id; $record->type = $type; $rtn = $record->save(); } return $rtn; }