protected function beforeSave() { if ($this->isNewRecord) { $this->createdDt = date("Y-m-d H:i:s"); $this->createdBy = Yii::app()->user->getId(); $this->statusId = 2; $unTitles = TransportStations::model()->findAll("title LIKE 'untitled%'"); $unTitleCount = count($unTitles) != 0 ? count($unTitles) + 1 : 1; $this->title = 'untitled-' . $unTitleCount; } $this->modifiedDt = date("Y-m-d H:i:s"); $this->modifiedBy = Yii::app()->user->getId(); return true; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = TransportStations::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }