public function actionRemove() { $portId = intval($_GET['portId']) ? intval($_GET['portId']) : ''; if (!$portId) { exit; } $port = Port::model()->findByPk($portId); // assuming there is a post whose ID is 10 $port->delete(); //$this->actionIndex(); $this->redirect(Yii::app()->request->urlReferrer); }
public function actionSearch() { $keyword = $_POST['keywords']; $port = $_POST['port']; $str = ''; echo header("Content-Type: text/html;charset=utf-8"); $model = NULL; if ($keyword) { $str = 'title like ' . '"' . '%' . $keyword . '%' . '"'; } if ($port) { if ($str != '') { $str .= ' and '; } $str .= ' port =' . '"' . $port . '"'; } $criteria = new CDbCriteria(); // 创建CDbCriteria对象 $criteria->condition = $str; // 设置查询条件 $model = Room::model()->findAll($criteria); $port = Port::model()->findAll(); $this->render('index', array('room' => $model, 'port' => $port)); }
public function actionAdd() { $port = Port::model()->findAll(); $this->render('add', array('port' => $port)); }
public function actionAdd() { $boat = Boat::model()->findAll(); $area = Area::model()->findAll(); $company = Company::model()->findAll(); $port = Port::model()->findAll(); $continent = Continent::model()->findAll(); $this->render('add', array('boat' => $boat, 'area' => $area, 'port' => $port, 'company' => $company, 'continent' => $continent)); }
public function actionSave_port() { $source = ''; $thumb = ''; if (isset($_POST['source'])) { $source = $_POST['source']; } if (isset($_POST['thumb'])) { $thumb = $_POST['thumb']; } Port::model()->updateByPk($_POST['id'], array('name' => $_POST['title'], 'area' => $_POST['area'], 'description' => $_POST['content'], 'source' => $source, 'thumb' => $thumb)); echo 1; }
/** * 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 = Port::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }