本文整理匯總了PHP中Teacher::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Teacher::validate方法的具體用法?PHP Teacher::validate怎麽用?PHP Teacher::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Teacher
的用法示例。
在下文中一共展示了Teacher::validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionIndex
/**
* 首頁
*/
public function actionIndex()
{
$teacherModel = new Teacher();
$studentModel = new Student();
$hostModel = new Host();
if (XUtils::method() == 'POST') {
/*switch($_POST){
case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master'; break;
case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break;
case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break;
default: $nowModel = 0;
}
if($nowModel){
$nowModel->attributes = $nowAttributes;
if ($nowModel->validate() && $nowModel->save()) {
parent::_stateWrite(
array(
'masterId' => $nowModel->id,
'name' => $nowModel->name,
), array('prefix' => '_master')
);
$cookie = new CHttpCookie('userName', $nowModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->redirect(array($nowRedirect));
}
}*/
if (isset($_POST['Teacher'])) {
$teacherModel->attributes = $_POST['Teacher'];
if ($teacherModel->validate() && $teacherModel->save()) {
parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master'));
if ($teacherModel->name == '') {
$teacherModel->name = '導師';
}
$cookie = new CHttpCookie('userName', $teacherModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $teacherModel->id);
$this->_cookiesSet('userType', 'student');
Yii::app()->user->setFlash('TSSuccess', '注冊成功!請完善個人信息並提交身份認證即可發布課程');
$this->redirect(array('/master'));
}
} else {
if (isset($_POST['Student'])) {
$studentModel->attributes = $_POST['Student'];
//echo CActiveForm::validate($studentModel);
if ($studentModel->validate() && $studentModel->save()) {
parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student'));
if ($studentModel->name == '') {
$studentModel->name = '學員';
}
$cookie = new CHttpCookie('userName', $studentModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $studentModel->id);
$this->_cookiesSet('userType', 'student');
$this->redirect(array('/student/info/sinfo'));
}
} else {
if (isset($_POST['Host'])) {
$hostModel->attributes = $_POST['Host'];
//echo CActiveForm::validate($hostModel);
if ($hostModel->validate() && $hostModel->save()) {
parent::_stateWrite(array('hostId' => $hostModel->id, 'name' => $hostModel->name), array('prefix' => '_host'));
if ($hostModel->name == '') {
$hostModel->name = '場地主';
}
$cookie = new CHttpCookie('userName', $hostModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $hostModel->id);
$this->_cookiesSet('userType', 'host');
$this->redirect(array('/host'));
}
}
}
}
}
$this->render('index', array('teacherModel' => $teacherModel, 'studentModel' => $studentModel, 'hostModel' => $hostModel));
}
示例2: actionIndex
/**
* 首頁
*/
public function actionIndex()
{
$teacherModel = new Teacher();
$studentModel = new Student();
$hostModel = new Host();
if (XUtils::method() == 'POST') {
/*switch($_POST){
case isset($_POST['Teacher']): $nowModel = new Teacher; $nowAttributes = $_POST['Teacher']; $nowRedirect = '/master'; break;
case isset($_POST['Student']): $nowModel = new Student; $nowAttributes = $_POST['Student']; $nowRedirect = '/student/info/sinfo'; break;
case isset($_POST['Host']): $nowModel = new Host; $nowAttributes = $_POST['Host']; $nowRedirect = '/host/default/Info'; break;
default: $nowModel = 0;
}
if($nowModel){
$nowModel->attributes = $nowAttributes;
if ($nowModel->validate() && $nowModel->save()) {
parent::_stateWrite(
array(
'masterId' => $nowModel->id,
'name' => $nowModel->name,
), array('prefix' => '_master')
);
$cookie = new CHttpCookie('userName', $nowModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->redirect(array($nowRedirect));
}
}*/
if (isset($_POST['Teacher'])) {
$teacherModel->attributes = $_POST['Teacher'];
$studentUser = Student::model()->countByAttributes(array('user' => $teacherModel->user));
$hostUser = Host::model()->countByAttributes(array('user' => $teacherModel->user));
//echo CActiveForm::validate($hostModel);
//判斷賬號與其他角色賬號是否相同
if ($studentUser != 0 || $hostUser != 0) {
Yii::app()->user->setFlash('TeacherUserError', '您的手機號已在其他角色注冊');
}
$tAgree = Yii::app()->request->getPost('teacherAgree');
if ($tAgree === NULL) {
Yii::app()->user->setFlash('teacherAgreeMessage', '同意條款未勾選');
}
if ($teacherModel->validate() && $studentUser == 0 && $hostUser == 0 && $tAgree === 'on' && $teacherModel->save()) {
parent::_stateWrite(array('masterId' => $teacherModel->id, 'name' => $teacherModel->name), array('prefix' => '_master'));
if ($teacherModel->name == '') {
$teacherModel->name = '導師';
}
$cookie = new CHttpCookie('userName', $teacherModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $teacherModel->id);
$this->_cookiesSet('userType', 'student');
Yii::app()->user->setFlash('TSSuccess', '注冊成功!請完善個人信息並提交身份認證即可發布課程');
$this->redirect(array('/master'));
}
} else {
if (isset($_POST['Student'])) {
$studentModel->attributes = $_POST['Student'];
//echo CActiveForm::validate($studentModel);
$teacherUser = Teacher::model()->countByAttributes(array('user' => $studentModel->user));
$hostUser = Host::model()->countByAttributes(array('user' => $studentModel->user));
//echo CActiveForm::validate($hostModel);
//判斷賬號與其他角色賬號是否相同
if ($teacherUser != 0 || $hostUser != 0) {
Yii::app()->user->setFlash('StudentUserError', '您的手機號已在其他角色注冊');
}
$sAgree = Yii::app()->request->getPost('studentAgree');
if ($sAgree === NULL) {
Yii::app()->user->setFlash('studentAgreeMessage', '同意條款未勾選');
}
$studentModel->register_time = date('Y-m-d H:m:s', time());
if ($studentModel->validate() && $teacherUser == 0 && $hostUser == 0 && $sAgree === 'on' && $studentModel->save()) {
parent::_stateWrite(array('studentId' => $studentModel->id, 'name' => $studentModel->name), array('prefix' => '_student'));
if ($studentModel->name == '') {
$studentModel->name = '學員';
}
$cookie = new CHttpCookie('userName', $studentModel->name);
Yii::app()->request->cookies['userName'] = $cookie;
$this->_cookiesSet('userId', $studentModel->id);
$this->_cookiesSet('userType', 'student');
$this->redirect(array('/student/info/sinfo'));
}
} else {
if (isset($_POST['Host'])) {
$hostModel->attributes = $_POST['Host'];
$teacherUser = Teacher::model()->countByAttributes(array('user' => $hostModel->user));
$studentUser = Student::model()->countByAttributes(array('user' => $hostModel->user));
//echo CActiveForm::validate($hostModel);
//判斷賬號與其他角色賬號是否相同
if ($studentUser != 0 || $teacherUser != 0) {
Yii::app()->user->setFlash('HostUserError', '您的手機號已在其他角色注冊');
}
$hAgree = Yii::app()->request->getPost('hostAgree');
if ($hAgree === NULL) {
Yii::app()->user->setFlash('hostAgreeMessage', '同意條款未勾選');
}
//.........這裏部分代碼省略.........