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


PHP Fn::db方法代码示例

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


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

示例1: report

    public function report($exam_id)
    {
        $sql1 = <<<EOT
SELECT count(1) as 'count' 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $sql2 = <<<EOT
SELECT rs.exam_ticket,CONCAT(rs.last_name,rs.first_name) as xname 
from rd_student rs,rd_exam_place_student reps , rd_exam_place rep 
where rep.exam_pid='{$exam_id}' and rep.place_id=reps.place_id and rs.uid=reps.uid
EOT;
        $result1 = Fn::db()->fetchRow($sql1);
        // 读取数据
        if ($result1['count'] > 0) {
            $sql3 = "SELECT exam_name FROM rd_exam WHERE exam_id={$exam_id}";
            $row = Fn::db()->fetchRow($sql3);
            $title = $row['exam_name'] . '.xls';
            $data = array();
            $data['list'] = $this->db->query($sql2)->result_array();
            $header = array('准考证号', '姓名');
            $excel_model = new ExcelModel();
            $excel_model->addHeader($header);
            $excel_model->addBody($data['list']);
            $excel_model->download($title);
        } else {
            echo '暂无学生,请先添加学生';
        }
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:29,代码来源:kyxm.php

示例2: schools

    public function schools()
    {
        $schools = array();
        $sql = <<<EOT
SELECT school_id, school_name FROM rd_school
EOT;
        $where = array();
        $bind = array();
        if ($keyword = trim($this->input->post('keyword'))) {
            $where[] = 'school_name LIKE ?';
            $bind[] = '%' . $keyword . '%';
        }
        if ($grade_id = intval($this->input->post('grade_id'))) {
            $grade_period = get_grade_period($grade_id);
            if ($grade_period) {
                $where[] = 'grade_period LIKE ?';
                $bind[] = '%' . $grade_period . '%';
            }
        }
        if ($where) {
            $sql .= ' WHERE ' . implode(' AND ', $where);
        }
        $schools = Fn::db()->fetchAll($sql, $bind);
        echo json_encode($schools);
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:25,代码来源:common.php

示例3: delarray

 private static function delarray($dbName, $array, $is_export_student)
 {
     // 处理传入进来的数组
     $tableList = array();
     foreach ($array as $tables) {
         if ($tables == '*') {
             // 所有的表(获得表名时不能按常规方式来组成一个数组)
             $sql = "SELECT table_name, table_type \n                        FROM information_schema.tables \n                        WHERE table_schema = '{$dbName}'";
             $stmt = Fn::db()->query($sql);
             while ($item = $stmt->fetch(PDO_DB::FETCH_ASSOC)) {
                 if (strtolower($item['table_type']) == 'view') {
                     $tableList['view'][] = $item['table_name'];
                 } else {
                     if (!$is_export_student && (is_int(strpos($item['table_name'], 'student')) || is_int(strpos($item['table_name'], 'summary')))) {
                         continue;
                     }
                     $tableList['table'][] = $item['table_name'];
                 }
             }
         } else {
             $tableList['table'] = $array;
             break;
         }
     }
     return $tableList;
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:26,代码来源:Dbmanage.php

示例4: __construct

 public function __construct()
 {
     parent::__construct();
     self::$_db = Fn::db();
     self::$_data = array();
     $this->load->model('cron/report/subject_report/common_model');
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:7,代码来源:choose_learn_choose_exam_model.php

示例5: get_type_list

    /**
     * 考试类型列表
     *          
     * @return  array
     */
    public static function get_type_list()
    {
        $sql = <<<EOT
SELECT * FROM rd_interview_type ORDER BY pid ASC
EOT;
        $rows = Fn::db()->fetchAll($sql);
        $list = array();
        foreach ($rows as $row) {
            if ($row['pid']) {
                $list[$row['pid']]['children'][$row['type_id']] = $row;
            } else {
                $list[$row['type_id']] = $row;
            }
        }
        // 分级排序
        $result = array();
        foreach ($list as $row) {
            $result[$row['type_id']] = $row;
            if (!empty($row['children'])) {
                $result = $result + $row['children'];
                unset($result[$row['type_id']]['children']);
            }
        }
        return $result;
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:30,代码来源:InterviewType.php

示例6: get_group_type_list

    /**
     * 按学科ID,父ID,读取信息提取方式列表
     *          
     * @param   int       学科ID
     * @param   int       上级ID
     * @return  array
     */
    public static function get_group_type_list($pid = 0, $subject_id = 0, $relate_num = TRUE, $relate_child = false)
    {
        static $result = array();
        $hash = $subject_id . '-' . $pid;
        if (isset($result[$hash])) {
            return $result[$hash];
        }
        $list = array();
        $sql = <<<EOT
SELECT * FROM rd_group_type WHERE pid = {$pid}
EOT;
        if ($subject_id) {
            $sql .= " AND subject_id = {$subject_id}";
        }
        $rows = Fn::db()->fetchAll($sql);
        foreach ($rows as $row) {
            $list[$row['id']] = $row;
        }
        if ($relate_num) {
            foreach ($list as &$val) {
                $val = self::get_group_type_num($val);
            }
        }
        if ($relate_child) {
            foreach ($list as &$val) {
                $val['childlist'] = array_values(self::get_group_type_list($val['id'], $val['subject_id'], false));
            }
        }
        $result[$hash] = $list;
        return $result[$hash];
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:38,代码来源:GroupType.php

示例7: get_role_list

 /**
  * 读取角色列表
  *          
  * @return  array
  */
 public static function get_role_list()
 {
     $rows = Fn::db()->fetchAll("SELECT * FROM rd_role");
     $list = array();
     foreach ($rows as $row) {
         $list[$row['role_id']] = $row;
     }
     return $list;
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:14,代码来源:Role.php

示例8: get_average

 /**
  * 获取平均值
  *
  * @param array $param 查询条件
  * @param string $field 查询字段
  * @return array 数据结果集
  */
 public static function get_average($param, $field)
 {
     PDO_DB::build_where($param, $where_sql, $bind);
     $sql = "SELECT AVG({$field}) AS {$field} FROM rd_interview_result";
     if ($where_sql) {
         $sql .= " WHERE {$where_sql}";
     }
     return Fn::db()->fetchRow($sql, $bind);
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:16,代码来源:InterviewResult.php

示例9: get_average

    /**
     * 获取平均值
     *
     * @param array $param 查询条件
     * @param string $field 查询字段
     * @return array 数据结果集
     */
    public static function get_average($param, $field)
    {
        PDO_DB::build_where($param, $where_sql, $bind);
        $sql = <<<EOT
SELECT AVG({$field}) AS {$field} FROM rd_ruidabei_result
EOT;
        if ($where_sql) {
            $sql .= " WHERE " . $where_sql;
        }
        return Fn::db()->fetchRow($sql, $bind);
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:18,代码来源:RuidabeiResult.php

示例10: insert

 /**
  * 添加 生成考试期次学生的成绩任务
  */
 public function insert($data)
 {
     if (empty($data['exam_pid'])) {
         return false;
     }
     $data['c_time'] = time();
     $data['status'] = 0;
     $exam_ticket_maprule = ExamModel::get_exam($data['exam_pid'], 'exam_ticket_maprule');
     if ($exam_ticket_maprule > 0) {
         $data['status'] = 1;
     }
     return Fn::db()->replace('rd_cron_task_exam_result', $data);
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:16,代码来源:cron_exam_result_model.php

示例11: get_admin_log

    public static function get_admin_log($log_info = '', $item = '*')
    {
        if ($log_info == '') {
            return FALSE;
        }
        $sql = <<<EOT
SELECT {$item} FROM rd_admin_log WHERE log_info = ?
EOT;
        $row = Fn::db()->fetchRow($sql, $log_info);
        if ($item && isset($row[$item])) {
            return $row[$item];
        } else {
            return $row;
        }
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:15,代码来源:AdminLog.php

示例12: get_question

    /**
     * 读取一个试题
     */
    public static function get_question($id = 0, $item = '*')
    {
        if ($id == 0) {
            return FALSE;
        }
        $sql = <<<EOT
SELECT {$item} FROM rd_interview_question WHERE id = {$id}
EOT;
        $row = Fn::db()->fetchRow($sql);
        if ($item && isset($row[$item])) {
            return $row[$item];
        } else {
            return $row;
        }
    }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:18,代码来源:InterviewQuestion.php

示例13: index

 /**
  * 控制界面首页
  */
 public function index($exam_pid = 0)
 {
     Fn::ajax_call($this, 'regenerateExamRecord', 'regenerateExamResults', 'endPlaceExam', 'regenerateSummaryReportData', 'regenerateReport', 'removeCronTaskReport');
     $exam_pid = intval($exam_pid);
     $param['exam_pid'] = 0;
     $param['exam_isfree'] = 0;
     $examlist = ExamModel::get_exam_list_all($param);
     $exam = array();
     if ($exam_pid > 0) {
         $exam = ExamModel::get_exam($exam_pid);
     }
     if (!$exam) {
         $exam = current($examlist);
     }
     $db = Fn::db();
     /////////////////////////考试记录是否生成/////////////
     $sql = "SELECT uid_data FROM rd_cron_task_place_student_paper ctps\n                LEFT JOIN rd_exam_place  ep ON ep.place_id = ctps.place_id\n                WHERE ep.exam_pid ={$exam['exam_id']} AND ctps.status=2";
     $uid_arr = $db->fetchCol($sql);
     $paper_count = 0;
     foreach ($uid_arr as $item) {
         $paper_count += count(json_decode($item));
     }
     $sql = "SELECT COUNT(*) FROM rd_exam_place_student eps\n               LEFT JOIN rd_exam_place ep ON ep.place_id = eps.place_id\n               WHERE ep.exam_pid = {$exam['exam_id']}";
     $student_count = $db->fetchOne($sql);
     if ($paper_count == $student_count) {
         $data['paper_status'] = true;
         //考试记录是否完全生成
     } else {
         $data['paper_status'] = false;
     }
     /////////////////////////////////////////
     $sql = "SELECT status FROM rd_cron_task_exam_result \n            WHERE exam_pid = {$exam['exam_id']}";
     $data['cter_status'] = $db->fetchOne($sql);
     //////////////////////////////////////////
     $sql = "SELECT DISTINCT(status) FROM rd_cron_task_report ctr \n                LEFT JOIN rd_evaluate_rule er ON er.id = ctr.rule_id \n                WHERE exam_pid =  {$exam['exam_id']}";
     $data['ctr_status'] = $db->fetchCol($sql);
     ////////////////////////////////////////
     $data['exam'] = $exam;
     $data['demo_exam'] = $this->demo_exam_list();
     $data['examlist'] = $examlist;
     $data['place'] = ExamPlaceModel::get_exam_place($exam_pid, 'MAX(end_time) as end_time');
     $data['crontaskexamresult'] = ReportCommandModel::cronTaskExamResultInfo($exam['exam_id']);
     $data['evaluerulelist'] = ReportCommandModel::cronTaskReportLists($exam['exam_id']);
     $this->load->view('report_command/index', $data);
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:48,代码来源:report_command.php

示例14: get_skills

 /**
  * 读取列表
  * @param   int $subject_id = 0 学科ID,为0表示不限学科
  * @return  map<int, variant>   获取某个学科(或不限学科)的所有技能列表
  */
 public static function get_skills($subject_id = 0)
 {
     static $result = array();
     $hash =& $subject_id;
     if (isset($result[$hash])) {
         return $result[$hash];
     }
     $sql = 'SELECT * FROM rd_skill';
     $list = array();
     if ($subject_id) {
         $sql .= ' WHERE subject_id = ' . $subject_id;
     }
     $rows = Fn::db()->fetchAll($sql);
     foreach ($rows as $row) {
         $list[$row['id']] = $row;
     }
     $result[$hash] = $list;
     return $list;
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:24,代码来源:Skill.php

示例15: init_distribution_paper_manual

 /**
  * 手动给参加考试的学生分配试卷及试题
  *
  * @return void
  */
 public function init_distribution_paper_manual()
 {
     set_time_limit(0);
     $db = Fn::db();
     $this->load->model('cron/cron_place_student_paper_model', 'init_model');
     /* 手动指定考场 */
     /* $places = array(57,58,59,60); */
     $places = array(60);
     $place_list = array();
     /* 获取考场学生 */
     foreach ($places as $key => $value) {
         $sql = "SELECT uid FROM rd_exam_place_student WHERE place_id='{$value}'";
         $place_list[$value]['uids'] = $db->fetchCol($sql);
     }
     $place_uids = array();
     $place_ids = array();
     foreach ($place_list as $place_id => $place) {
         $exam_pid = $place['exam_pid'];
         foreach ($place['uids'] as $uid) {
             //给学生分配试卷
             $result = $this->init_model->init_test_paper($place_id, $uid);
             if ($result) {
                 $place_ids[$exam_pid][$place_id][] = $uid;
             }
         }
     }
     //给考场学生分配试题
     if ($place_ids) {
         foreach ($place_ids as $exam_pid => $place) {
             foreach ($place as $place_id => $uids) {
                 $uids = array_unique($uids);
                 $this->init_model->init_test_question($exam_pid, $place_id, $uids);
             }
         }
     }
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:41,代码来源:exam_place_student_paper.php


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