Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 13.59.58.68
<?php
function getmasQPDet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$fdeggrp = $aobj_context->mobj_data['fdeggrp'];
$fexmrng = $aobj_context->mobj_data['fexamrange'];
$fexamno = str_split($fexmrng);
$fexamno = join("','",$fexamno);
// $drop_query = "drop temporary table if exists tmpmasqp1";
// $dropRes = $aobj_context->pobj_db->Execute($drop_query);
// var_dump($fdeggrp,$fexmrng);
// die();
$crtTmpTbl = "create temporary table tmpmasqp1
( fqpcode varchar(10) primary key,
fsubname varchar(200),
fexamno varchar(1),
fdeggrp varchar(10),
fdegreerange varchar(500)
)";
$tmpRes = $aobj_context->pobj_db->Execute($crtTmpTbl);
// var_dump($aobj_context);
// die();
$inserttoTmpTbl = "insert into tmpmasqp1(fqpcode, fsubname, fexamno, fdeggrp, fdegreerange)
select fqpcode, fsubname, s.fexamno, fdeggrp,
group_concat(s.fdegree order by s.fdegree separator ' / ' )
from subject s inner join degree d on s.fdegree = d.fdegree
and s.fexamno = d.fexamno
where ifnull(fqpcode,'') <> ''
group by fqpcode";
$insertRes = $aobj_context->pobj_db->Execute($inserttoTmpTbl);
if($insertRes){
$inserttoMasQP = "insert ignore into masqp(fqpcode, fsubname, fexamno, fdeggrp, fdegreerange)
select fqpcode, fsubname, fexamno, fdeggrp, fdegreerange from tmpmasqp1";
$insertMasQPRes = $aobj_context->pobj_db->Execute($inserttoMasQP);
$upMasQP = "update masqp x, tmpmasqp1 y
set x.fsubname = y.fsubname,
x.fexamno = y.fexamno,
x.fdeggrp = y.fdeggrp,
x.fdegreerange = y.fdegreerange
where x.fqpcode = y.fqpcode";
$upMasQPRes = $aobj_context->pobj_db->Execute($upMasQP);
$query = "select fqpcode, fsubname, fexamno, ifnull(fboard,'') as fboard, fdeggrp, fdegreerange from masqp
where fdeggrp = '{$fdeggrp}' and fexamno in ('{$fexamno}')
order by fexamno, fboard, fqpcode";
$result = $aobj_context->pobj_db->getAll($query);
// var_dump($result);
if($result){
// $arr['msg'] = "Updation was Successfull";
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}else{
$arr['msg'] = "Failed to get data, please try later..!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}else{
$arr['msg'] = "Something Please Try Later..!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function saveMasQP($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$data = $aobj_context->req_body['data'];
// var_dump($data);
$values = "";
foreach ($data as $k => $v) {
$values .= "('{$v['fqpcode']}', '{$v['fsubname']}', '{$v['fexamno']}','{$v['fboard']}','{$v['fdeggrp']}','{$v['fdegreerange']}'),";
}
$values = rtrim($values, ',');
$query = "insert into masqp (fqpcode,fsubname,fexamno,fboard,fdeggrp,fdegreerange) values {$values}
ON DUPLICATE KEY UPDATE
fsubname = values(fsubname), fboard = values(fboard)";
$result = $aobj_context->pobj_db->Execute($query);
if($result){
$arr['msg'] = "Updation was Successfull";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}else{
$arr['msg'] = "Failed to update, please try later..!";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
?>
|