本文整理匯總了PHP中Courses::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Courses::create方法的具體用法?PHP Courses::create怎麽用?PHP Courses::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Courses
的用法示例。
在下文中一共展示了Courses::create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
public static function create($data)
{
session_start();
$headers = apache_request_headers();
$token = $headers['X-Auth-Token'];
if (!$headers['X-Auth-Token']) {
header('Invalid CSRF Token', true, 401);
return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
} else {
if ($token != $_SESSION['form_token']) {
header('Invalid CSRF Token', true, 401);
return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
} else {
if (!isset($data['coursecode']) && empty($data['coursecode'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Course Code is required'), JSON_PRETTY_PRINT);
die;
} else {
if (!isset($data['coursename']) && empty($data['coursename'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Course Description is required'), JSON_PRETTY_PRINT);
die;
} else {
if (!isset($data['passing_score']) && empty($data['passing_score'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Passing Score Limit is required'), JSON_PRETTY_PRINT);
die;
} else {
$var = ["coursecode" => $data['coursecode'], "coursename" => $data['coursename'], "passing_score" => $data['passing_score']];
Courses::create($var);
}
}
}
}
}
}