本文整理汇总了PHP中Course::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::create方法的具体用法?PHP Course::create怎么用?PHP Course::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doInsert
function doInsert()
{
if (isset($_POST['savecourse'])) {
if ($_POST['coursename'] == "" or $_POST['coursedesc'] == "") {
message("All field is required!", "error");
check_message();
} else {
$course = new Course();
$coursename = $_POST['coursename'];
$courselevel = $_POST['level'];
$coursemajor = $_POST['major'];
$coursedesc = $_POST['coursedesc'];
$coursedept = $_POST['dept'];
$res = $course->find_all_course($coursename, $courselevel, $coursemajor);
if ($res >= 1) {
message("Course name already exist!", "error");
check_message();
} else {
$course->COURSE_NAME = $coursename;
$course->COURSE_LEVEL = $courselevel;
$course->COURSE_MAJOR = $coursemajor;
$course->COURSE_DESC = $coursedesc;
$course->DEPT_ID = $coursedept;
$istrue = $course->create();
if ($istrue == 1) {
message("New [" . $coursename . "] course created successfully!", "success");
redirect('index.php');
}
}
}
}
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Course::create(['courseName' => $faker->word, 'courseStart' => $faker->time($format = 'H:i', $max = 'now'), 'courseEnd' => $faker->time($format = 'H:i', $max = 'now'), 'section_id' => rand(1, 9)]);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$courses = [['name' => 'Introduction to Computer Programming', 'code' => 'CSE101', 'credits' => 3], ['name' => 'Introduction to Mathematics', 'code' => 'MAT101', 'credits' => 3], ['name' => 'World History', 'code' => 'HST102', 'credits' => 3], ['name' => 'Microprocessors', 'code' => 'CSE341', 'credits' => 3], ['name' => 'Database Design', 'code' => 'CSE370', 'credits' => 3], ['name' => 'Introduction to Programming in Unix', 'code' => 'CSE410', 'credits' => 3]];
foreach ($courses as $key => $course) {
Course::create($course);
}
}
示例4: create
function create(Course $obj)
{
$columns = array('name');
$output = array('code' => '000', 'message' => 'Something gone wrong. Please try again', 'type' => 'danger');
if ($obj->create($_REQUEST['name'])) {
$output = array('code' => '200', 'message' => 'Course created successfully.', 'type' => 'success');
}
return $output;
}
示例5: add_course_POST
function add_course_POST()
{
$name = _post('name');
$teacher = _post('teacher');
$description = _post('description');
if ($name && $teacher) {
$course = Course::create(compact('name', 'teacher', 'description'));
redirect('course/' . $course->id);
} else {
show_form();
}
}
示例6: create
function create()
{
Auth::checkLoggedIn();
// Make sure the user is an admin
if (!Auth::getUser()->isAdmin()) {
throw new Exception('Only admins may create new courses.');
}
// Create a new course
$course = Course::create(Auth::getUser(), 'New course', 'NOT-SET-00');
// Rendet the context for the new course
View::renderJson($course->getContext(Auth::getUser()));
}
示例7: createCourse
public function createCourse()
{
//check if the course already exist...
$all = Input::all();
$course = Course::where('course_name', '=', $all['course_name'])->first();
if ($course) {
return Response::jsend('fail', array('msg' => sprintf("Course name %s is already exist. Please create course with another name.", $all['course_name'])));
} else {
//create new course details.
$course = Course::create($all);
//after successfully creating Course
//$id = $course->id;
return Response::jsend('success', array('msg' => 'Course successfully created.'));
}
}
示例8: run
public function run()
{
Course::create(array('uid' => 'IT-210', 'name' => 'Business Systems Analysis', 'about' => '', 'ownerid' => 1, 'members' => serialize(array(1)), 'boards' => serialize(array()), 'files' => serialize(array())));
}
示例9: function
* 課程管理
*/
Route::group(array('prefix' => 'course', 'before' => 'auth'), function () {
// 顯示課程名稱
Route::get('/', function () {
$courseList = Course::orderBy('course_name')->get();
return View::make('course')->with(array('courseList' => $courseList));
});
// 執行新增課程
Route::post('/add', function () {
$validator = FormValidator::course(Input::all());
if ($validator->fails()) {
return Redirect::to('/course')->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
if (Course::create($data)) {
$message = '新增課程《' . $data['course_name'] . '》完成';
} else {
$message = '資料寫入錯誤';
}
return Redirect::to('/course')->with('message', $message);
}
});
// 執行編輯課程
Route::post('/edit/{id}', function ($id) {
$validator = FormValidator::course(Input::all());
if ($validator->fails()) {
return Redirect::to('/course')->withInput()->withErrors($validator)->with('message', '輸入錯誤,請檢查');
} else {
$data = Input::all();
$course = Course::find($id);
示例10: Course
<?php
require_once "../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
redirect_to("index.php");
}
if ($_POST['oper'] == 'add') {
$course = new Course();
$course->code = $_POST['code'];
$course->description = $_POST['description'];
$course->curriculum_id = $_POST['curriculum_id'];
$course->create();
} else {
if ($_POST['oper'] == 'edit') {
$course = Course::get_by_id($_POST['id']);
$course->code = $_POST['code'];
$course->description = $_POST['description'];
$course->curriculum_id = $_POST['curriculum_id'];
$course->update();
} else {
if ($_POST['oper'] == 'del') {
Course::get_by_id($_POST['id'])->delete();
}
}
}
示例11: header
if ($results == 0) {
print "No results.";
exit;
} else {
header('Content-type: application/json');
print json_encode($results);
exit;
}
}
$cid = $_GET['cid'];
$assignments = Course::findByCid($cid)->getAssignments();
header("Content-type: application/json");
print json_encode($assignments);
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Create a course (must be professor)
$login = $_COOKIE['login'];
// Check if professor? //
$title = $_POST['title'];
$new_course = Course::create($login, $title);
if ($new_course == null) {
header("HTTP/1.0 500 Server Error");
print "Could not create new class.";
exit;
} else {
header("Content-type: application/json");
print $new_course->getJSON();
exit;
}
}
示例12: varchar
`image_url` varchar(250) DEFAULT '',
PRIMARY KEY (`notificationid`),
KEY `userid` (`userid`),
CONSTRAINT `user_notification_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`userid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET foreign_key_checks = 1;
STR;
$install_query = Database::connection()->prepare($install_sql);
if (!$install_query->execute()) {
View::renderView('install_result', array('result' => 'Nothing was done. Query failed.'));
exit;
}
try {
$install_query->fetchAll();
} catch (Exception $ex) {
unset($ex);
}
// Now create the first user
$admin = User::create('Admin', 'Admin', 'admin@admin.com', 'abc123');
// Make the user an admin
$adminQuery = Database::connection()->prepare('UPDATE user SET is_admin = 1 WHERE userid = ?');
$adminQuery->bindValue(1, $admin->getUserId(), PDO::PARAM_INT);
$adminQuery->execute();
$adminQuery->fetchAll();
// Create an initial course
Course::create($admin, 'Test Course', 'testcourse-001');
// We're doing the installation
View::renderView('install_result', array('result' => 'Installed! Close and delete this script.'));
exit;
}
View::renderView('install_splash', array('show_button' => true, 'result' => 'Database connection was successful.'));
示例13: header
require_once 'core/init.php';
$member_role = $_SESSION['roles'];
if (in_array("Laboratory Administrator", $member_role)) {
} else {
header('location:restricted_page.php');
}
if (count($_POST) > 0) {
$course_data = array("course_id" => null, "course_no" => $_POST["course_no"], "course_name" => $_POST["course_name"]);
$_SESSION['form_data'] = $course_data;
header("Location: fixed_schedule.php", true, 303);
die;
} else {
if (isset($_SESSION['form_data'])) {
$new_course = new Course();
$new_course->create($_SESSION["form_data"]);
if ($new_course->addCourse()) {
$message = "You have successfully Registered the Course !!";
echo "<script type='text/javascript'>alert('{$message}');</script>";
} else {
$message = "The Course Registration was unsuccessful.";
echo "<script type='text/javascript'>alert('{$message}');</script>";
}
unset($_SESSION["form_data"]);
}
}
?>
<!DOCTYPE html>
<html>
示例14: Exception
$updateDone = true;
Course::updateCode($courseId, $newCourseCode);
}
if (!$updateDone) {
throw new Exception("No new data inputted. Process aborted.");
}
//
header('Location: ' . BASE_URL . 'academia/courses/success');
} else {
throw new Exception("Either you're trying to hack this app or something wrong went. In either case the\n developers were just notified about this");
}
} else {
if (isBtnSavePrsd()) {
$newCourseCode = trim($_POST['course_code']);
$newCourseName = trim($_POST['course_name']);
Course::create($newCourseCode, $newCourseName);
header('Location: ' . BASE_URL . 'academia/courses/success');
exit;
} else {
if (isBtnDeletePrsd()) {
Course::delete($_POST['delCourseIdModal']);
header('Location: ' . BASE_URL . 'academia/courses/success');
exit;
}
}
}
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
/**
* http://stackoverflow.com/a/4128377/2790481
示例15: header
<?php
require_once 'core/init.php';
$member_role = $_SESSION['roles'];
if (in_array("Laboratory Administrator", $member_role)) {
} else {
header('location:restricted_page.php');
}
if (count($_POST) > 0) {
$course_data = array("course_id" => null, "course_no" => $_POST["course_no"], "course_name" => $_POST["course_name"]);
$new_course = new Course();
$new_course->create($course_data);
if ($new_course->addCourse()) {
$message = "You have successfully Registered the Course !!";
echo $message;
} else {
$message = "The Course Registration was unsuccessful.";
echo $message;
}
}
?>