本文整理汇总了PHP中Subject::get_by_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Subject::get_by_sql方法的具体用法?PHP Subject::get_by_sql怎么用?PHP Subject::get_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject::get_by_sql方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Grade
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$objPHPExcel->setActiveSheetIndex(0);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
// COLUMNS
$SUBJECT = 0;
$STUDENT_ID = 1;
$NAME = 2;
$GRADE = 3;
//SUBJECT
$subject_code = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow(0, 2)->getValue();
$subject = Subject::get_by_sql("SELECT * FROM tbl_subjects WHERE code = '" . $subject_code . "'")[0];
if ($subject) {
$subject_id = Subject::get_by_sql("SELECT * FROM tbl_subjects WHERE code = '" . $subject_code . "'")[0]->id;
for ($row = 2; $row <= $highestRow; $row++) {
$student_id = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($STUDENT_ID, $row)->getValue();
$grade = $objPHPExcel->getActiveSheet()->getCellByColumnAndRow($GRADE, $row)->getValue();
$student = Student::get_by_id($student_id);
if ($student) {
$grades = Grade::get_by_sql("SELECT * FROM tbl_student_grades WHERE subject_id = '" . $subject_id . "' AND student_id = " . $student_id)[0];
if ($grades) {
$grades->grade = $grade;
$grades->update();
} else {
$newgrades = new Grade();
$newgrades->grade = $grade;
$newgrades->student_id = $student_id;
$newgrades->subject_id = $subject_id;
$newgrades->create();
示例2: foreach
}
if (!$sidx) {
$sidx = 1;
}
$first = $_GET['first'];
if ($first == "true") {
$future_sem = 1;
} else {
if ($first == "2nd") {
$future_sem = 2;
} else {
$future_sem = $student->semester == 1 ? 2 : 1;
}
}
//$student_subjects = Grade::get_by_sql("SELECT * FROM " . T_STUDENT_GRADES . " WHERE ".C_GRADE_STUDENT_ID."=".$student->id);
$future_subjects = Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS . " WHERE " . C_SUBJECT_COURSE_ID . "=" . $student->course_id . " AND " . C_SUBJECT_SEMESTER . " = " . $future_sem . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
// $student_current_subjects = array();
// foreach($student_subjects as $student_subject)
// {
// array_push($student_current_subjects, Subject::get_by_id($student_subject->subject_id));
// }
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
if (count($future_subjects) > 0) {
foreach ($future_subjects as $final_subject) {
$s .= "<row id='" . $final_subject->id . "'>";
$s .= "<cell>" . $final_subject->id . "</cell>";
示例3: redirect_to
require_once "../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
redirect_to("index.php");
}
if ($_POST['oper'] == 'del') {
Subject::get_by_id($_POST['id'])->delete();
}
if ($_POST['prereq_subject_code'] == "NOTHING" || $_POST['prereq_subject_code'] == "") {
$prereq_subject_id = 0;
} else {
$prereq_subject_id = Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS . " WHERE " . C_SUBJECT_CODE . "='" . trim($_POST['prereq_subject_code']) . "'")[0]->id;
}
$course_id = Course::get_by_sql("SELECT * FROM " . T_COURSES . " WHERE " . C_COURSE_CODE . "='" . trim($_POST['course_code']) . "'")[0]->id;
$rows = Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS . " WHERE " . C_SUBJECT_CODE . "='" . $_POST['code'] . "' AND " . C_SUBJECT_COURSE_ID . "=" . $course_id);
if ($_POST['oper'] == 'add') {
if (count($rows) > 0) {
die("exists");
}
$subject = new Subject();
$subject->code = $_POST['code'];
$subject->description = $_POST['description'];
$subject->units = $_POST['units'];
$subject->prereq_subject_id = $prereq_subject_id;
$subject->course_id = $course_id;
$subject->year = $_POST['year'];
$subject->semester = $_POST['semester'];
$subject->curriculum_id = $_POST['curriculum_id'];
$subject->create();
} else {
示例4:
if ($page > $total_pages) {
$page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
$start = 0;
}
if (!$sidx) {
$sidx = 1;
}
if (isset($_GET['searchString']) && isset($_GET['searchField'])) {
$searchString = $_GET['searchString'];
$searchField = $_GET['searchField'];
$subjects = Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS . " WHERE " . $searchField . " LIKE '%" . $searchString . "%' ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
} else {
$subjects = Subject::get_by_sql("SELECT * FROM " . T_SUBJECTS . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
}
if ($isteacher) {
$subjects = TeacherSubject::get_by_teacher_id($session->user_id);
}
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($subjects as $subjectobject) {
$subject = $subjectobject;
if ($isteacher) {
$subject = Subject::get_by_id($subjectobject->subject_id);
}