public function getTplByKey($key) { $tpl = TplSMS::model()->findByAttributes(array('alias_key' => $key)); if (!$tpl) { self::log('Unknown tpl sms'); } return $tpl; }
public function actionUpdate($new = false) { if ($new === true) { $model = new TplSMS(); $this->pageName = Yii::t('app', 'CREATE', 1); } else { $model = TplSMS::model()->findByPk($_GET['id']); $this->pageName = Yii::t('app', 'UPDATE', 1); } if (!$model) { throw new CHttpException(400); } if (Yii::app()->request->isPostRequest) { $model->attributes = $_POST['TplSMS']; if ($model->validate()) { $model->save(); } } $this->render('update', array('model' => $model)); }