本文整理汇总了PHP中Current::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Current::model方法的具体用法?PHP Current::model怎么用?PHP Current::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current
的用法示例。
在下文中一共展示了Current::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionResults
public function actionResults()
{
$student_id = Yii::app()->request->getQuery("student_id", NULL);
$current = Current::model()->find('student_id=:student_id', array(':student_id' => $student_id));
$all_sessions = Session::model()->findAll('mod_id=:mod_id', array(':mod_id' => $current->mod_id));
$all = array();
foreach ($all_sessions as $key0 => $session) {
$session_id = $session->session_id;
$session_listenings = SessionListening::model()->findAll('session_id=:session_id', array(':session_id' => $session_id));
$all[$key0]["session_id"] = $session->session_id;
$all[$key0]["session_name"] = $session->session_name;
$all[$key0]["session_order"] = $session->session_order;
$all[$key0]["mod_id"] = $session->mod_id;
$all[$key0]["listenings"] = array();
foreach ($session_listenings as $key => $session_listening) {
$temp_listening_id = $session_listening->listening_id;
$listening = Listening::model()->find('listening_id=:listening_id', array(':listening_id' => $temp_listening_id));
$all[$key0]["listenings"][$key] = array('listening_id' => $listening->listening_id, 'listening_name' => $listening->listening_name, 'listening_repeat_number' => $listening->listening_repeat_number, 'listening_learning_guide_availability' => $listening->listening_learning_guide_availability);
$criteria = new CDbCriteria();
$criteria->addCondition("listening_id=:listening_id");
//$criteria->order='RAND()';
$criteria->params = array(':listening_id' => $listening->listening_id);
$questions = Question::model()->findAll($criteria);
//$questions=Question::model()->findAll('listening_id=:listening_id',array('listening_id'=>$listening->listening_id));
foreach ($questions as $key2 => $question) {
$all[$key0]["listenings"][$key]['questions'][$key2] = array('question_id' => $question->question_id, 'question_body' => $question->question_body, 'question_correct_answer_id' => $question->question_correct_answer_id);
$criteria = new CDbCriteria();
$criteria->addCondition("question_id=:question_id");
//$criteria->order='RAND()';
$criteria->params = array(':question_id' => $question->question_id);
$answers = Answer::model()->findAll($criteria);
//$answers=Answer::model()->findAll('question_id=:question_id',array(':question_id'=>$question->question_id));
foreach ($answers as $key3 => $answer) {
$all[$key0]["listenings"][$key]['questions'][$key2]['answers'][$key3] = array('answer_id' => $answer->answer_id, 'answer_body' => $answer->answer_body);
}
}
}
}
$this->render('results', array('all' => $all, 'student_id' => $student_id));
}
示例2: actionPushLogin
public function actionPushLogin()
{
$student_username = Yii::app()->request->getPost("student_username", NULL);
$student_password = Yii::app()->request->getPost("student_password", NULL);
$student = Student::model()->find('student_username=:student_username', array(':student_username' => $student_username));
if ($student) {
if ($student->student_password == hash('sha512', $student_password . Yii::app()->params['salt'])) {
$current = Current::model()->find('student_id=:student_id', array('student_id' => $student->student_id));
$mod = Mod::model()->find('mod_id=:mod_id', array('mod_id' => $current->mod_id));
$response = array('student_id' => $student->student_id, 'student_username' => $student->student_username, 'student_name' => $student->student_name, 'student_surname' => $student->student_surname, 'mod_name' => $mod->mod_name);
$this->renderJSON($response);
} else {
$this->renderJSON(array('status' => 0, 'message' => 'either username or password is not correct!'));
}
} else {
$this->renderJSON(array('status' => 0, 'message' => 'there is no such a user registered!'));
}
}
示例3: loadModel
/**
* 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 $id the ID of the model to be loaded
* @return Current the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Current::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}