public function actionEdit() { $msgHost = ""; $request = Yii::app()->getRequest(); $id = trim($request->getParam("id")); if (!empty($_POST)) { $ip = trim($request->getPost("ip")); $admin = trim($request->getPost("admin")); $username = trim($request->getPost("username")); $password = trim($request->getPost("password")); $provider = trim($request->getPost("provider")); $status = trim($request->getPost("status")); if ($ip == "") { $msgHost = "主机IP选项不能留空"; } else { if (strlen($ip) > 64) { $msgHost = "输入不能大于64个字符"; } } if ($msgHost == "") { $host = array('ip' => $ip, 'admin' => $admin, 'username' => $username, 'password' => $password, 'provider' => $provider, 'status' => $status); try { $res = new Host(); $res->_pk = $id; $res->_attributes = $host; $res->setIsNewRecord(false); $res->update(); $this->redirect(array('list')); } catch (CDbException $e) { throw CDbException($e); } } } try { $Rs = new Host(); $rsInfo = $Rs->findByPk($id); } catch (CDbException $e) { throw CDbException($e); } $this->render('edit', array('r' => Yii::app()->request->baseUrl . '/', 'rsInfo' => $rsInfo, 'msgHost' => $msgHost)); }