Viewing file: mo_rg_studentsummary.php (7.27 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("da_rg_StudentSummary.php");
class Mo_rg_studentsummary extends Da_rg_StudentSummary {
/**
* หน้าที่ของฟังก์ชั่น คือ หาข้อมูลสรุปผลการเรียนนักศึกษาตามเงื่อนไข
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขของคำสั่ง SELECT
* @param array order โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการเรียงลำดับ ORDER BY
* @param array group โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการจัดกลุ่ม GROUP BY
* @return query >= 1 rows : rg_StudentSummary.*
*/
public function qrySsm($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *
FROM $this->rg_dbname.rg_StudentSummary
$c1
$c3
$c2";
$query = $this->db->query($sql);
return $query;
}
// use
public function qrySsmJoinTm($condition="") {
$con = $this->checkCondition($condition);
$con= substr($con, 0, -3);
$sql = "SELECT *
FROM $this->rg_dbname.rg_StudentSummary
INNER JOIN $this->rg_dbname.rg_Term ON ssmTmId = tmId
$con
ORDER BY ssmAcY, ssmTmId";
$query = $this->db->query($sql);
return $query;
}
// use
public function qrySsmJoinTmSst($condition="") {
$con = $this->checkCondition($condition);
$con= substr($con, 0, -3);
$sql = "SELECT *
FROM $this->rg_dbname.rg_StudentSummary
INNER JOIN $this->rg_dbname.rg_Term ON ssmTmId = tmId
INNER JOIN $this->rg_dbname.rg_StudentStatus ON ssmSstId=sstId
$con
ORDER BY ssmAcY, ssmTmId";
$query = $this->db->query($sql);
return $query;
}
// use
function GetSumCreditPointByStIdAndAcY($stId, $acY) {
$sql = "SELECT SUM(ssmCreditPoint) as num
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId= ? AND ssmAcY = ?";
$query = $this->db->query($sql,array($stId, $acY));
if($query->num_rows()) {
if(is_null($query->row()->num)) {
return 0;
} else {
return $query->row()->num;
}
} else {
return 0;
}
}
// use
function GetSumCreditPointByStId($stId){
$sql = "SELECT SUM(ssmCreditPoint) as num
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId= ?";
$query = $this->db->query($sql,array($stId));
if ($query->num_rows()) {
return $query->row()->num;
} else {
return 0;
}
}
// use
function getSsmOrderLast($stId) {
$sql = "SELECT * FROM $this->rg_dbname.rg_StudentSummary
where ssmStdId = ?
ORDER BY ssmAcY DESC, ssmTmId DESC";
$query = $this->db->query($sql,array($stId));
return $query;
}
// use
public function qryByStdIdAndMaxTmIdInMaxAcY($stdId) {
$sql = "SELECT
rg_StudentSummary.ssmGPAX
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId=?
AND ssmAcY=(SELECT
MAX(rg_StudentSummary.ssmAcY)
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId=?)
AND ssmTmId=(SELECT
MAX(rg_StudentSummary.ssmTmId)
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId=?
AND ssmAcY=(SELECT
MAX(rg_StudentSummary.ssmAcY)
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId=?))";
$query = $this->db->query($sql,array($stdId,$stdId,$stdId,$stdId));
return $query;
}
// use
function getCountStdIdBycurIdAdYTmPassStatus($curId, $adY, $acY, $tm, $passStatus){
$sql = "SELECT count(stdId) as num
FROM $this->rg_dbname.rg_StudentSummary
INNNER JOIN $this->rg_dbname.rg_Student ON stdId = ssmStdId
WHERE stdCurId = ?
AND stdAdY = ?
AND ssmAcY = ?
AND ssmTmId = ?
AND ssmPassStatus = ?
AND ssmSstId !=4 ";
$query = $this->db->query($sql,array($curId, $adY, $acY, $tm, $passStatus));
if ($query->num_rows()) {
return $query->row()->num;
} else {
return 0;
}
}
public function getMaxAcYByCurIdAdYSyId($curId, $adY, $syId, $ssmSstId = '') {
$cond = ($ssmSstId != '')?" AND ssmSstId IN ($ssmSstId) ":'';
$sql = "SELECT MAX(ssmAcY) AS num
FROM $this->rg_dbname.rg_Student
INNER JOIN $this->rg_dbname.rg_StudentSummary ON stdId = ssmStdId
WHERE stdCurId = ?
AND stdAdY = ?
AND stdSyId = ? $cond ";
$query = $this->db->query($sql, array($curId, $adY, $syId));
return $query->row()->num;
}
function getMaxTmIdByCurIdAdYSyIdAcY($curId, $adY, $syId, $acY, $ssmSstId = '') {
$cond = ($ssmSstId != '')?" AND ssmSstId IN ($ssmSstId) ":'';
$sql = "SELECT MAX(ssmTmId) AS num
FROM $this->rg_dbname.rg_Student
INNER JOIN $this->rg_dbname.rg_StudentSummary ON stdId = ssmStdId
WHERE stdCurId = ?
AND stdAdY = ?
AND stdSyId = ?
AND ssmAcY = ? $cond ";
$query = $this->db->query($sql, array($curId, $adY, $syId, $acY));
return $query->row()->num;
}
// use
function getMaxAcYByStdId($stdId) {
$sql = "SELECT MAX(ssmAcY) AS num
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId = ?";
$query = $this->db->query($sql, array($stdId));
return $query->row()->num;
}
// use
function getMaxTmIdByStdIdAcY($stdId, $acY) {
$sql = "SELECT MAX(ssmTmId) AS num
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId = ?
AND ssmAcY = ?";
$query = $this->db->query($sql, array($stdId, $acY));
return $query->row()->num;
}
/**
* หน้าที่ของฟังก์ชั่น คือ หาข้อมูลนักศึกษารายภาค
*
* @access public
* @param $stdId: รหัสนักศึกษา
* @param $acY: ปีการศึกษา
* @param $ssmPassStatusStr: string การเลื่อนชั้น
* @return query >= 1 rows : rg_StudentStatus.*
*/
public function qrySsmByStdIdAndAcYAndSsmPassStatusStr($stdId,$acY,$ssmPassStatusStr) {
$sql = "SELECT *
FROM $this->rg_dbname.rg_StudentSummary
WHERE ssmStdId=?
AND ssmAcY=?
ANd ssmPassStatus IN (?)";
$query = $this->db->query($sql,array($stdId,$acY,$ssmPassStatusStr));
return $query;
}
public function qrySsmSst($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *
FROM $this->rg_dbname.rg_StudentSummary
INNER JOIN $this->rg_dbname.rg_StudentStatus ON ssmSstId=sstId
$c1
$c3
$c2";
$query = $this->db->query($sql);
return $query;
}
}
?>
|