<?php

// 根据课程分类获取课程列表
require_once ("../user_include.inc");

ErrorLogger::doOutput("Compass...ajax_get_course_by_category.php....Start.", 0);

//获取参数
$parentId = ParamUtil::getRequestNumber("parentId", 0);
$subId = ParamUtil::getRequestNumber("subId", 0);
$page = ParamUtil::getRequestNumber("page", 0);

//每页显示条数
$rowCount = 10;

$result = array();

$offset = $page * $rowCount;

//检索数据库
$param = array();
$param['parent_category_id'] = $parentId;
$param['sub_category_id'] = $subId;
$param['delete_flg'] = false;
$mediaList = CourseMediaDat::getList($param,'id','desc', $offset, $rowCount);
$allCount = CourseMediaDat::getListCount($param);
$pageCount = ceil($allCount/$rowCount);

//接口返回数据
$result["rowCount"] = $rowCount;
$result["page"] = $page;
$result["pageCount"] = $pageCount;
$result["list"] = $mediaList;


ErrorLogger::doOutput("Compass...ajax_get_course_by_category.php....End.", 0);


//返回结果
responseOK($result);

function responseNG($result) {
	$result = array("status"=>"NG", "result"=>$result);
	print json_encode($result);
	exit;
}
function responseOK($result) {
	$result = array("status"=>"OK", "result"=>$result);
	print json_encode($result);
	exit;
}
?>