0
나는 coba2를위한 조절기를 가지고 있습니다. 정수가 아닌 정수로 검색하는 경우는 SQL 오류 여기yii는 admim 페이지에서 검색을 유효화합니다.
CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "a" LINE 1: SELECT COUNT(*) FROM "yii_user" "t" WHERE id_user='a' ^. The SQL statement executed was: SELECT COUNT(*) FROM "yii_user" "t" WHERE id_user=:ycp0
을 줄 것이기 때문에 기능 actionAdmin에 내가 검색에 유효성 검사를 추가 할 것입니다 것은
public function actionAdmin()
{
$model=new coba2('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['coba2']))
$model->attributes=$_GET['coba2'];
if($model->validate()){
$this->render('admin',array(
'model'=>$model,
));
} else{
$model->unsetAttributes();
$this->render('admin',array(
'model'=>$model,
));
}
}
내 모델에 기능을 검증 호출 내 기능입니다 여기 내 모델의 규칙이 있습니다
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('username, password, salt, date_create, date_update, date_birth', 'required'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id_user', 'numerical', 'integerOnly'=>true, 'on'=>'search'),
array('id_user, username, password, salt, date_create, date_update, date_birth', 'safe', 'on'=>'search'),
);
}
죄송합니다. 영어가 좋지 않지만 도움이 필요합니다. 감사는 :)
무엇 질문입니까? – Pentium10