wonderwong 2012-12-14 01:54:00 3096次浏览 1条回复 0 0 0
public function actionEdit(){
    $admin_id = Yii::app()->request->getParam('admin_id');
    $username = Yii::app()->request->getParam('username');
    $password = Yii::app()->request->getParam('password');

    if(Yii::app()->request->isPostRequest){
        $data = array('username' => $username,'password' => $password);
        $count =Admin::model()->updateByPk($admin_id,$data); 
        //$adminModel->findByPk($admin_id);
        //s$adminModel ->attributes=$data;
        if($count){
            $this->redirect(Yii::app()->baseUrl.'/admin/admin/index/');
        }
    }
    $adminModel = new Admin();
    $condition="admin_id=".$admin_id;
    $adminInfo = $adminModel->find($condition,array('id','username'));
    $this->render('edit',array('admininfo'=>$adminInfo));
}

报这个错误

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1. The SQL statement executed was: SELECT * FROM `webgame_admin` `t` WHERE admin_id= LIMIT 1
  • 回复于 2012-12-14 11:44 举报

    从这句sql SELECT * FROM webgame_admin t WHERE admin_id= LIMIT 1 来看,好像是admin_id这个url参数没有获取到。

您需要登录后才可以回复。登录 | 立即注册