当前位置: 首页>>代码示例>>PHP>>正文


PHP Fn::db_pg方法代码示例

本文整理汇总了PHP中Fn::db_pg方法的典型用法代码示例。如果您正苦于以下问题:PHP Fn::db_pg方法的具体用法?PHP Fn::db_pg怎么用?PHP Fn::db_pg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fn的用法示例。


在下文中一共展示了Fn::db_pg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: syncZmossExamResults

 /**
  * 将阅卷系统成绩同步到测评系统中
  * @param   int     $er_examid    考试id
  * @param   int     $er_zmoss_examid 阅卷考试id
  * @return  bool    true|false
  */
 public static function syncZmossExamResults($er_examid, $er_zmoss_examid)
 {
     if (!Validate::isInt($er_examid) || $er_examid <= 0 || !Validate::isInt($er_zmoss_examid) || $er_zmoss_examid <= 0) {
         return false;
     }
     $db = Fn::db();
     $examrelate = self::examRelateInfo($er_examid, $er_zmoss_examid);
     if (!$examrelate || !$examrelate['er_exampid']) {
         return false;
     }
     $examrelatequestion = self::examRelateQuestionInfo($er_examid, $er_zmoss_examid);
     if (!$examrelatequestion) {
         return false;
     }
     $sql = "SELECT COUNT(*) FROM rd_exam_test_result\n                WHERE exam_id = ?";
     if (!$db->fetchOne($sql, array($er_examid))) {
         return false;
     }
     $questionrelate = array();
     foreach ($examrelatequestion as $item) {
         $questionrelate[$item['erq_paperid']] = json_decode($item['erq_relate_data'], true);
     }
     $psql = Fn::db_pg();
     $zmoss_examid = $examrelate['er_zmoss_examid'];
     //检查考试阅卷是否已完成
     $sql = "SELECT exam_id FROM t_exam\n                WHERE exam_id = ? AND exam_flag = 6";
     if (!$psql->fetchRow($sql, array($zmoss_examid))) {
         return false;
     }
     //查询所有学生客观题得分
     $sql = "SELECT stu_exam_ticket, soqa_quesid, soqa_testscore, ques_fullscore\n                FROM t_student\n                LEFT JOIN v_student_objective_question_answer ON soqa_stuid = stu_id\n                WHERE soqa_examid = ? AND soqa_flag = 1";
     $stmt = $psql->query($sql, array($zmoss_examid));
     $list = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $list[trim($row['stu_exam_ticket'])][$row['soqa_quesid']] = array('full_score' => $row['ques_fullscore'], 'test_score' => $row['soqa_testscore']);
     }
     if (!$list) {
         return false;
     }
     //查询所有学生主观题得分
     $sql = "SELECT stu_exam_ticket, ques_id, ques_fullscore, etsq_testscore\n                FROM t_student\n                LEFT JOIN t_evaluation_task_student_question ON etsq_stuid = stu_id\n                LEFT JOIN t_question ON ques_id = etsq_quesid\n                WHERE ques_examid = ?";
     $stmt = $psql->query($sql, array($zmoss_examid));
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $list[trim($row['stu_exam_ticket'])][$row['ques_id']] = array('full_score' => $row['ques_fullscore'], 'test_score' => $row['etsq_testscore']);
     }
     if (!$db->beginTransaction()) {
         return false;
     }
     $sql = "SELECT etp.etp_id, etp.paper_id, s.external_account, etp.uid\n                FROM rd_exam_test_paper etp\n                LEFT JOIN rd_student s ON s.uid = etp.uid\n                WHERE etp.exam_id = ?";
     $stmt = $db->query($sql, array($er_examid));
     $uids = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         @(list($etp_id, $paper_id, $exam_ticket, $uid) = array_values($row));
         $uids[] = $uid;
         $exam_ticket = trim($exam_ticket);
         $ques_score = $list[$exam_ticket];
         if (!$ques_score) {
             continue;
         }
         $question = $questionrelate[$paper_id];
         if (!$question) {
             continue;
         }
         foreach ($question as $ques_id => $zmoss_quesid) {
             $bind = array('full_score' => $ques_score[$zmoss_quesid]['full_score'], 'test_score' => $ques_score[$zmoss_quesid]['test_score']);
             $db->update('rd_exam_test_result', $bind, 'etp_id = ? AND (ques_id = ? OR sub_ques_id = ?)', array($etp_id, $ques_id, $ques_id));
         }
     }
     if ($uids) {
         foreach ($uids as $uid) {
             ExamstatModel::calculatePaperScore($examrelate['er_exampid'], $uid);
             //计算试卷得分
         }
     }
     $sql = "SELECT COUNT(*) FROM t_exam_relate\n                WHERE er_exampid = ? AND er_flag < 3";
     if (!$db->fetchOne($sql, array($examrelate['er_exampid']))) {
         //所有考场均已完成成绩导入计算
         ExamstatModel::updateQuestionScore($examrelate['er_exampid'], 0, true);
         //更新试题分数
         ExamstatModel::updateExamQuestionstat($examrelate['er_exampid']);
         //更新试卷试题答题情况
         $bind = array('exam_pid' => $examrelate['er_exampid'], 'status' => 1, 'c_time' => time());
         $db->replace('rd_cron_task_exam_result', $bind);
     }
     $flag = $db->commit();
     if (!$flag) {
         $db->rollBack();
     }
     return $flag;
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:96,代码来源:Zmoss.php


注:本文中的Fn::db_pg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。