本文整理汇总了PHP中Fn类的典型用法代码示例。如果您正苦于以下问题:PHP Fn类的具体用法?PHP Fn怎么用?PHP Fn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
self::$_db = Fn::db();
self::$_data = array();
$this->load->model('cron/report/subject_report/common_model');
}
示例2: 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];
}
示例3: beforeAction
protected function beforeAction($action)
{
$this->_controller = $action->getController()->getId();
$this->_action = $action->getId();
$this->returnurl = Fn::url_login_current();
$token = FCookie::get("auth");
$now = time();
list($uid, $email, $timeout) = explode("\t", FHelper::auth_code($token, 'DECODE', FF_SALT));
if ($uid) {
$userInfo = $this->getUserinfo($uid);
if ($userInfo['user']['id']) {
if ($token == $userInfo['user']['token']) {
if ($now < $timeout) {
$this->userInfo = $userInfo['info'];
$this->user = $userInfo['user'];
if ($timeout - $now < 60 * 2) {
$timeout = time() + 60 * 15;
$token = FHelper::auth_code("{$uid}\t{$email}\t{$timeout}", 'ENCODE', FF_SALT);
FCookie::set('auth', $token, 60 * 15);
$attr = array('token' => $token);
$user_model = new User();
$user_model->updateByPk($uid, $attr);
}
// $timeout = time()+60 *15;
// $token = FHelper::auth_code("$uid\t$email\t$timeout", 'ENCODE', FF_SALT);
// FCookie::set('auth', $token);
}
}
}
}
return true;
}
示例4: 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 '暂无学生,请先添加学生';
}
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
示例8: getHTML
public function getHTML()
{
if (Config::get('debug')) {
return $this->html;
} else {
return Fn::minifyHTML($this->html);
}
}
示例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 = "SELECT AVG({$field}) AS {$field} FROM rd_interview_result";
if ($where_sql) {
$sql .= " WHERE {$where_sql}";
}
return Fn::db()->fetchRow($sql, $bind);
}
示例10: each
public static function each($view, $collection, $item = 'item', array $scope = array())
{
if (Fn::iterable($collection)) {
$tmpl = $tmpl = Ant::init()->fromFile($view);
foreach ($collection as $single) {
$scope[$item] = $single;
echo $tmpl->assign($scope)->draw();
}
}
}
示例11: 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);
}
示例12: 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);
}
示例13: 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;
}
}
示例14: 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;
}
}
示例15: 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);
}