/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aBoardMember !== null) { if ($this->aBoardMember->isModified() || $this->aBoardMember->isNew()) { $affectedRows += $this->aBoardMember->save($con); } $this->setBoardMember($this->aBoardMember); } if ($this->aCommittee !== null) { if ($this->aCommittee->isModified() || $this->aCommittee->isNew()) { $affectedRows += $this->aCommittee->save($con); } $this->setCommittee($this->aCommittee); } if ($this->isNew()) { $this->modifiedColumns[] = BoardCommitteePeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = BoardCommitteePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += BoardCommitteePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Committee(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Committee'])) { $model->attributes = $_POST['Committee']; $model->members = implode(',', $model->members); if ($model->save() && $model->validate()) { date_default_timezone_set("Asia/Manila"); $activity = new Activity(); $activity->act_desc = 'Added a Committee'; $activity->act_datetime = date('Y-m-d G:i:s'); $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id; $activity->save(); $this->redirect(array('view', 'id' => $model->comm_id)); } } $this->render('create', array('model' => $model)); }