function __construct($host, $username, $password, $db)
 {
     $conn_para = "mysql:{$host};{$db};charset=utf8";
     $opt = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC);
     $this->_pdo = new PDO($conn_para, $username, $password, $opt) or die('There is problem in connecting to database');
     $this->_pdo->exec("USE " . $db);
     self::$_instance = $this;
 }
Example #2
0
 /**
  * 获取平均值
  *
  * @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);
 }
Example #3
0
 public static function get_v_schools($where = array())
 {
     $sql = "SELECT * FROM v_school";
     PDO_DB::build_where($where, $where_sql, $bind);
     if ($where_sql) {
         $sql .= " WHERE {$where_sql}";
     }
     $rows = Fn::db()->fetchAll($sql, $bind);
     return $rows;
 }
Example #4
0
    /**
     * 获取所有评分项
     *
     * @param array $params 查询条件
     * @param string $fields 需要查询的字段,默认为 *
     * @return array 成功返回结果数组,失败返回空数组
     */
    public static function get_options_all($params, $fields = '*')
    {
        $sql = <<<EOT
SELECT {$fields} FROM rd_evaluation_option
EOT;
        PDO_DB::build_where($params, $where_sql, $bind);
        if ($where_sql) {
            $sql .= ' WHERE ' . $where_sql;
        }
        return Fn::db()->fetchAll($sql, $bind);
    }
Example #5
0
    /**
     * 获取平均值
     *
     * @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);
    }
Example #6
0
    /**
     * 获取试卷数量
     *
     * @param   array  $param 查询条件
     * @return  mixed   指定单个字段则返回该字段值,否则返回关联数组
     */
    public static function count_papers($param)
    {
        PDO_DB::build_where($param, $where_sql, $bind);
        $sql = <<<EOT
SELECT COUNT(*) FROM rd_exam_paper
EOT;
        if ($where_sql) {
            $sql .= ' WHERE ' . $where_sql;
        }
        return Fn::db()->fetchOne($sql, $bind);
    }
    /**
     * 获取多条
     *
     * @param array $params 查询条件
     * @param string $fields 需要查询的字段,默认为 *
     * @param int $limit 查询的条数,默认为 15
     * @return array 成功返回结果数组,失败返回空数组
     */
    public static function get_multiterm($params, $fields = '*', $limit = 15)
    {
        $sql = <<<EOT
SELECT {$fields} FROM rd_evaluation_standard
EOT;
        PDO_DB::build_where($params, $where_sql, $bind);
        if ($where_sql) {
            $sql .= ' WHERE ' . $where_sql;
        }
        $sql .= ' ORDER BY id DESC';
        if (is_string($limit)) {
            $args = explode(',', $limit);
            $sql .= ' LIMIT ' . $args[1] . ' OFFSET ' . $args[0];
        } else {
            $sql .= ' LIMIT ' . $limit;
        }
        return Fn::db()->fetchAll($sql, $bind);
    }
Example #8
0
 /**
  * 更新考试信息
  * array $data
  * mixed $where
  * return boolean
  */
 public static function update($data, $where)
 {
     PDO_DB::build_where($where, $where_sql, $bind);
     return Fn::db()->update('rd_exam', $data, $where_sql, $bind) > 0;
 }