public function loadModel($id) { $model = Support::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $hotline = Support::model()->findAll('t.active=1 AND t.delete=0'); $htmlHotline = ''; foreach ($hotline as $item) { if (!empty($item->phone)) { $htmlHotline = $htmlHotline . $item->phone . ' (' . $item->name . ') - '; } } echo substr($htmlHotline, 0, -2);
public function getTypeOptions() { return CHtml::listData(Support::model()->findAll(), 'id', 'description'); }
public function actionDeleteAll($id) { $arrIdNew = explode(",", $id); for ($i = 0; $i < count($arrIdNew); $i++) { // Delete all news of category new $model = $this->loadModel($arrIdNew[$i]); if (!empty($model)) { $criteria = new CDBCriteria(); $criteria->addCondition("group_support_id = {$arrIdNew[$i]}"); $criteria->select = "id"; $arrSupport = Support::model()->findALl($criteria); foreach ($arrSupport as $support) { $model_support = Support::model()->find($support->id); $model_support->delete(); } } // Delete category new $model->delete(); } if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } }