本文整理汇总了PHP中Subjects::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Subjects::model方法的具体用法?PHP Subjects::model怎么用?PHP Subjects::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subjects
的用法示例。
在下文中一共展示了Subjects::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Subjects::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: codes
public function codes($attribute, $params)
{
$flag = 0;
$subject = Subjects::model()->findAllByAttributes(array('batch_id' => $this->batch_id, 'is_deleted' => 0));
foreach ($subject as $subject_1) {
if ($subject_1->name == $this->name) {
$flag = 1;
}
}
if ($flag == 1) {
$this->addError($attribute, 'This subject is already added');
}
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Exams();
$model_1 = new ExamGroups();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Exams'])) {
//$model->attributes=$_POST['Exams'];
if (isset($_REQUEST['exam_group_id'])) {
$insert_id = $_REQUEST['exam_group_id'];
} else {
$model_1->attributes = $_POST['ExamGroups'];
$model_1->batch_id = $_REQUEST['id'];
$model_1->save();
$insert_id = Yii::app()->db->getLastInsertID();
}
$posts = Subjects::model()->findAll("batch_id=:x AND no_exams=:y", array(':x' => $_REQUEST['id'], ':y' => 0));
$list = $_POST['Exams'];
$count = count($list['subject_id']);
$j = 0;
for ($i = 0; $i < $count; $i++) {
if ($list['maximum_marks'][$i] != NULL and $list['minimum_marks'][$i] != NULL and $list['start_time'][$i] != NULL and $list['end_time'][$i] != NULL) {
$model = new Exams();
$model->exam_group_id = $insert_id;
$model->subject_id = $list['subject_id'][$i];
$model->maximum_marks = $list['maximum_marks'][$i];
$model->minimum_marks = $list['minimum_marks'][$i];
$model->start_time = $list['start_time'][$i];
$model->end_time = $list['end_time'][$i];
if ($model->start_time) {
$date1 = date('Y-m-d H:i', strtotime($model->start_time));
$model->start_time = $date1;
}
if ($model->end_time) {
$date2 = date('Y-m-d H:i', strtotime($model->end_time));
$model->end_time = $date2;
}
$model->grading_level_id = $list['grading_level_id'];
$model->weightage = $list['weightage'];
$model->event_id = $list['event_id'];
$model->created_at = $list['created_at'];
$model->updated_at = $list['updated_at'];
$model->save();
}
}
$this->redirect(array('exams/create', 'id' => $_REQUEST['id'], 'exam_group_id' => $_REQUEST['exam_group_id']));
}
$this->render('create', array('model' => $model, 'model_1' => $model_1));
}
示例4: DropDown
public static function DropDown($SepcialityID = 0, $Level = 0)
{
$res = array();
$c = new CDbCriteria();
$c->order = 'SubjectName';
//if ($SepcialityID == 0){
foreach (Subjects::model()->findAll($c) as $record) {
$res[$record->idSubjects] = $record->SubjectName;
}
// } else {
//
// $ssubj = Specialitysubjects::model()->find("SpecialityID=:SpecialityID and LevelID = :LevelID",
// array(":SpecialityID"=>$SepcialityID,":LevelID"=>$Level));
// if (!empty($ssubj->subject)){
// $res[$ssubj->subject->idSubjects] = $ssubj->subject->SubjectName;
// } else {
// foreach(Subjects::model()->findAll() as $record) {
// $res[$record->idSubjects] = $record->SubjectName;
// }
// }
// }
return $res;
}
示例5: subjectname
public function subjectname($data, $row)
{
$subject = Subjects::model()->findByAttributes(array('id' => $data->subject_id));
return $subject->name;
}
示例6: array
</table>
<h3><?php
echo Yii::t('examination', ' Enter exam related details here:');
?>
</h3>
<div class="tableinnerlist">
<table width="95%" cellspacing="0" cellpadding="0">
<?php
if (isset($_REQUEST['id'])) {
$posts = Subjects::model()->findAll("batch_id=:x AND no_exams=:y", array(':x' => $_REQUEST['id'], ':y' => 0));
if (count($posts) != 0) {
$c = count($posts);
$i = 1;
$j = 0;
foreach ($posts as $posts_1) {
$c--;
$checksub = Exams::model()->findByAttributes(array('exam_group_id' => $_REQUEST['exam_group_id'], 'subject_id' => $posts_1->id));
if ($checksub == NULL) {
if ($j == 0) {
?>
<?php
echo $form->labelEx($model, 'max_mark');
?>
<?php
echo $form->textField($model, 'max_mark', array('id' => 'max_mark'));
示例7: actionZno
/**
* Метод асинхронно повертає список предметів ЗНО
*/
public function actionZno()
{
$models = Subjects::model()->findAll('idZNOSubject>0 ORDER BY SubjectName ASC');
$result = array();
foreach ($models as $model) {
/* @var $model Subjects */
$result[] = array('text' => $model->SubjectName, 'id' => $model->idSubjects);
}
echo CJSON::encode($result);
}
示例8: actionDelete
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
if (Yii::app()->request->isPostRequest) {
$model = ExamScores::model()->findByAttributes(array('id' => $id));
$student = Students::model()->findByAttributes(array('id' => $model->student_id));
$student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name);
$exam = Exams::model()->findByAttributes(array('id' => $model->exam_id));
$subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id));
$examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id));
$batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id));
$exam_name = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')';
$goal_name = $student_name . ' for the exam ' . $exam_name;
// we only allow deletion via POST request
$this->loadModel($id)->delete();
//Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '22', $model->id, $goal_name, NULL, NULL, NULL);
// we only allow deletion via POST request
//$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
} else {
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
}
示例9: array
<?php
echo '<span>' . Yii::t('Batch', 'Notice') . '</span>';
?>
<?php
echo Yii::t('Batch', 'Time Table Not Created.');
?>
<br />
<?php
echo CHtml::link(Yii::t('Batch', 'Create Now'), array('weekdays/timetable', 'id' => $_REQUEST['id']));
?>
</div>
<?php
}
?>
<?php
$sub = Subjects::model()->findByAttributes(array('batch_id' => $batch->id));
if ($sub == NULL) {
?>
<div class="notifications nt_red">
<?php
echo '<span>' . Yii::t('Batch', 'Notice') . '</span>';
?>
<?php
echo Yii::t('Batch', 'No Subjects Added');
?>
.<br />
<?php
echo CHtml::link(Yii::t('Batch', 'Add Now'), array('#'), array('id' => 'add_subjects-side'));
?>
</div>
<?php
示例10: array
// 'Specialitysubjects'=>array('index'),
// 'Manage',
//);
$this->menu = array(array('label' => 'Перелік предметів напрямів', 'url' => array('admin'), 'icon' => "icon-plus"), array('label' => 'Додати предмет напрямкку', 'url' => array('create'), 'icon' => "icon-plus"));
Yii::app()->clientScript->registerScript('search', "\r\n\$('.search-button').click(function(){\r\n\t\$('.search-form').toggle();\r\n\treturn false;\r\n});\r\n\$('.search-form form').submit(function(){\r\n\t\$.fn.yiiGridView.update('specialitysubjects-grid', {\r\n\t\tdata: \$(this).serialize()\r\n\t});\r\n\treturn false;\r\n});\r\n");
?>
<h1>Управління предметами напрямків</h1>
<p>
You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<!--
<?php
echo CHtml::link('Advanced Search', '#', array('class' => 'search-button btn'));
?>
<div class="search-form" style="display:none">
<?php
$this->renderPartial('_search', array('model' => $model));
?>
</div> search-form -->
<?php
$data = $model->search();
$Specialities = new Specialities();
$d = $Specialities->getSpecialityFullNames();
$this->widget('bootstrap.widgets.TbGroupGridView', array('id' => 'specialitysubjects-grid', 'type' => 'striped bordered condensed', 'dataProvider' => $data, 'filter' => $model, 'mergeColumns' => array('SpecialityID'), 'columns' => array(array('name' => 'SpecialityID', 'value' => '$data->speciality->SpecialityDirectionName." ".$data->speciality->SpecialitySpecializationName." (".
(($data->speciality->PersonEducationFormID==1)?("денна"):(($data->speciality->PersonEducationFormID==2)?("заочна"):("екстернат"))).")"', 'filter' => $d), array('name' => 'SubjectID', 'value' => '$data->subject->SubjectName', 'filter' => CHtml::listData(Subjects::model()->findAll(), "idSubjects", "SubjectName")), array('name' => 'LevelID', 'filter' => array("1" => "1", "2" => "2", "3" => "3"), "htmlOptions" => array("style" => "width: 100px")), array('name' => 'isProfile', 'filter' => array('1' => 'так', '0' => 'ні'), "htmlOptions" => array("style" => "width: 100px"), 'value' => '($data->isProfile)? "так":"ні"'), array('class' => 'bootstrap.widgets.TbButtonColumn'))));
示例11: actionBookSearch
public function actionBookSearch()
{
if (isset($_POST['search'])) {
if (isset($_POST['search']) && isset($_POST['text'])) {
$criteria = new CDbCriteria();
$criteria->compare('is_deleted', 0);
// normal DB field
$criteria->condition = 'is_deleted=:is_del';
$criteria->params = array(':is_del' => 0);
if ($_POST['search'] == 1) {
$sub = Subjects::model()->findByAttributes(array('name' => $_POST['text']));
if ($sub != NULL) {
$criteria->condition = 'subject LIKE :match';
$criteria->params = array(':match' => $sub->id . '%');
}
}
if ($_POST['search'] == 2) {
$criteria->condition = 'title LIKE :match';
$criteria->params = array(':match' => $_POST['text'] . '%');
}
if ($_POST['search'] == 3) {
$author = Author::model()->findByAttributes(array('author_name' => $_POST['text']));
if ($author != NULL) {
$criteria->condition = 'author LIKE :match';
$criteria->params = array(':match' => $author->auth_id . '%');
}
}
if ($_POST['search'] == 4) {
$criteria->condition = 'isbn LIKE :match';
$criteria->params = array(':match' => $_POST['text'] . '%');
}
}
$total = Book::model()->count($criteria);
$pages = new CPagination($total);
$pages->setPageSize(Yii::app()->params['listPerPage']);
$pages->applyLimit($criteria);
// the trick is here!
$posts = Book::model()->findAll($criteria);
$this->render('booksearch', array('list' => $posts, 'pages' => $pages, 'item_count' => $total, 'page_size' => Yii::app()->params['listPerPage']));
} else {
$this->render('booksearch');
}
}
示例12: array
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'specialitysubjects-form', 'enableAjaxValidation' => false));
$form = new TbActiveForm();
?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php
if (empty($SpecialityID)) {
$SpecialityID = 0;
}
echo CHtml::dropDownList("SpecialityID", $SpecialityID, Specialities::DropDown(), array('empty' => "", 'class' => 'span5'));
$c = new CDbCriteria();
$c->order = 'SubjectName';
$c->compare('idZNOSubject', '>0');
$data = CHtml::listData(Subjects::model()->findAll($c), "idSubjects", "SubjectName");
$dataCount = count($data);
?>
<div class ="row-fluid">
<?php
echo $form->error($models[0], "SpecialityID");
?>
</div>
<div class ="row-fluid">
<?php
foreach ($models as $i => $model) {
?>
<div class="span4">
<?php
echo $form->error($model, "[{$i}]SubjectID");
示例13: actionWhoHasSubjectTomorrow
public function actionWhoHasSubjectTomorrow($subject_id)
{
$semester = Semesters::model()->actual();
if (!$semester) {
throw new CException('Нет семестра');
}
$tomorrow_date = (new DateTime())->add(new DateInterval("P1D"))->format('Y-m-d');
$tomorrow_time = strtotime($tomorrow_date);
if (Holiday::model()->findByAttributes(['date' => $tomorrow_date]) || date('N', $tomorrow_time) == 7) {
throw new CException('Завтра выходной');
}
$week_number = ($semester->week_number + (date('W', $tomorrow_time) - date('W', strtotime($semester->start_date)))) % 2 ? 1 : 2;
$week_day = date('N', $tomorrow_time);
/** @var Subjects $subject */
$subject = Subjects::model()->findByPk($subject_id);
if (!$subject) {
throw new CException('Нет такого предмета');
}
/** @var GroupReplace[] $replaces */
$replaces = $subject->getRelated('replaces', true, ['with' => 'group', 'condition' => 'date = :tomorrow_date', 'params' => [':tomorrow_date' => $tomorrow_date]]);
/** @var ScheduleElement[] $schedule_elements */
$schedule_elements = $subject->getRelated('schedule_elements', true, ['with' => 'group', 'condition' => 'week_number = :week_number AND week_day = :week_day AND semester_id = :semester_id', 'params' => [':week_number' => $week_number, ':week_day' => $week_day, ":semester_id" => $semester->id]]);
$schedule = [];
if ($schedule_elements) {
foreach ($schedule_elements as $schedule_element) {
/** @var GroupReplace $replace */
if ($replace = GroupReplace::model()->findByAttributes(['date' => $tomorrow_date, 'number' => $schedule_element->number, 'group_id' => $schedule_element->group_id])) {
if ($replace->subject_id != $subject_id) {
continue;
}
}
$schedule[$schedule_element->number][] = (int) $schedule_element->group->number;
}
}
if ($replaces) {
foreach ($replaces as $replace) {
if (!isset($schedule[$replace->number])) {
$schedule[$replace->number] = [];
}
if (!in_array((int) $replace->group->number, $schedule[$replace->number])) {
$schedule[$replace->number][] = (int) $replace->group->number;
}
}
}
ksort($schedule);
$schedule_text = 'У кого завтра ' . $subject->name . '?' . PHP_EOL;
if (count($schedule)) {
foreach ($schedule as $number => $groups) {
$schedule_text .= $number . ') ' . implode(', ', $groups) . PHP_EOL;
}
} else {
$schedule_text .= 'А мы не знаем :-(' . PHP_EOL;
}
$schedule_text .= PHP_EOL . 'Данные предоставлены проектом @studyschedule (Расписание ККЭП)';
$params = http_build_query(['owner_id' => $this->owner_id, 'message' => $schedule_text, 'from_group' => 1, 'access_token' => $this->access_token]);
if ($result = file_get_contents('https://api.vk.com/method/wall.post?' . $params)) {
var_dump(json_decode($result, true));
} else {
echo 'Error when send request...';
}
echo PHP_EOL;
}
示例14: actionUpdate
public function actionUpdate($id)
{
$model = ExamScores::model()->findByAttributes(array('id' => $id));
$old_model = $model->attributes;
// For activity feed
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['ExamScores'])) {
$model->attributes = $_POST['ExamScores'];
$exam = Exams::model()->findByAttributes(array('id' => $_REQUEST['exam_id']));
if ($model->marks < $exam->minimum_marks) {
$model->is_failed = 1;
} else {
$model->is_failed = '';
}
if ($model->save()) {
// Saving to activity feed
$results = array_diff_assoc($model->attributes, $old_model);
// To get the fields that are modified.
foreach ($results as $key => $value) {
if ($key != 'updated_at') {
$student = Students::model()->findByAttributes(array('id' => $model->student_id));
$student_name = ucfirst($student->first_name) . ' ' . ucfirst($student->middle_name) . ' ' . ucfirst($student->last_name);
$subject_name = Subjects::model()->findByAttributes(array('id' => $exam->subject_id));
$examgroup = ExamGroups::model()->findByAttributes(array('id' => $exam->exam_group_id));
$batch = Batches::model()->findByAttributes(array('id' => $examgroup->batch_id));
$exam_name = ucfirst($subject_name->name) . ' - ' . ucfirst($examgroup->name) . ' (' . ucfirst($batch->name) . '-' . ucfirst($batch->course123->course_name) . ')';
$goal_name = $student_name . ' for the exam ' . $exam_name;
if ($key == 'is_failed') {
if ($value == 1) {
$value = 'Fail';
} else {
$value = 'Pass';
}
if ($old_model[$key] == 1) {
$old_model[$key] = 'Fail';
} else {
$old_model[$key] = 'Pass';
}
}
//Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '21', $model->id, $goal_name, $model->getAttributeLabel($key), $old_model[$key], $value);
}
}
//END saving to activity feed
if ($_REQUEST['allexam'] == 1) {
$url = 'default/allexam';
} else {
$url = 'default/classexam';
}
$this->redirect(array($url, 'bid' => $_REQUEST['bid'], 'exam_group_id' => $_REQUEST['exam_group_id'], 'r_flag' => $_REQUEST['r_flag'], 'exam_id' => $_REQUEST['exam_id']));
}
}
$this->render('examination/examination', array('model' => $model));
}
示例15: array
$sel = '';
}
echo '<div class="formCon"><div class="formConInner"><div style="float:left; width:380px;"><span style="font-size:14px; font-weight:bold; color:#666;">Course</span> ';
echo CHtml::dropDownList('id', '', $data, array('prompt' => 'Select', 'onchange' => 'course()', 'id' => 'cou', 'options' => array($sel => array('selected' => true))));
echo '</div>';
echo '<div style="float:left; width:300px;"><span style="font-size:14px; font-weight:bold; color:#666;">Subject</span> ';
?>
<?php
$data_1 = array();
if (isset($_REQUEST['cou'])) {
$batches = Batches::model()->findAll("course_id=:x and is_deleted=:y", array(':x' => $_REQUEST['cou'], ':y' => 0));
/*$data_1=Subjects::model()->findAll(array('join' => 'JOIN batches ON batch_id = batches.id','condition'=>'batches.course_id=:id',
'params'=>array(':id'=>(int) $_REQUEST['cou'])));*/
$data_1 = CHtml::listData(Subjects::model()->findAll(array('join' => 'JOIN batches ON batch_id = batches.id', 'condition' => 'batches.course_id=:id and elective_group_id=:x', 'params' => array(':id' => (int) $_REQUEST['cou'], ':x' => 0))), 'id', 'batchname');
}
if (isset($_REQUEST['sub'])) {
$sel_1 = $_REQUEST['sub'];
} else {
$sel_1 = '';
}
echo CHtml::dropDownList('sub', '', $data_1, array('prompt' => 'Select', 'onchange' => 'course()', 'id' => 'sub', 'onchange' => 'batch()', 'options' => array($sel_1 => array('selected' => true))));
echo '<br/></div><div class="clear"></div></div></div>';
?>
<?php
if (isset($_REQUEST['sub'])) {
$emp_sub = EmployeesSubjects::model()->findAll("subject_id=:x", array(':x' => $_REQUEST['sub']));
if (count($emp_sub) == 0) {
echo '<br> <br>' . Yii::t('employees', '<i>No Employee assigned yet.</i>') . '<br> <br>';