本文整理汇总了PHP中Course::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::add方法的具体用法?PHP Course::add怎么用?PHP Course::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add()
{
$translator = new Translator();
$course = new Course();
try {
$data = array('name' => '', 'category_id' => 0, 'format_id' => 0, 'prerequisites' => '', 'language' => 0, 'describe' => '', 'skills' => '', 'duration' => 0, 'equipment' => '', 'min' => 0, 'max' => 0, 'author' => '', 'questions' => 0, 'active' => 'false', 'exam' => 'false', 'need_approve' => 'false', 'exam_duration' => 0);
foreach ($data as $key => $val) {
if (isset($_POST[$key])) {
$data[$key] = $_POST[$key];
}
}
$course->add($data);
if (isset($_FILES['file'])) {
$this->uploadFiles($id);
}
echo <<<EOF
<div class="container">
<div class="page-header">
<h1>{$translator->Course_updated}</h1>
</div>
<p class="lead">{$translator->Course_updated_Desc}</p>
<p >{$translator->Error_Backadmincourses}</p>
</div>
<script type="text/javascript">
</script>
EOF;
} catch (Exception $e) {
echo <<<EOF
<div class="container">
<div class="page-header">
<h1>{$translator->Course_error}</h1>
</div>
<p class="lead">{$translator->Course_error_Desc}</p>
<p >{$translator->Error_Backadmincourses}</p>
</div>
EOF;
}
}
示例2: testgroundTask
/**
* Display default page
*
* @return void
*/
public function testgroundTask()
{
if (0) {
// CREATE COUPON
include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCoupon.php';
try {
// Constructor take the coupon code
$coupon = new Coupon('hui');
// Coupon description (shows up in the cart)
$coupon->setDescription('Test coupon, 10% off product with ID 3');
// Expiration date
$coupon->setExpiration('Feb 22, 2022');
// Number of times coupon can be used (unlimited by default)
$coupon->setUseLimit(1);
// Product the coupon will be applied to:
// first parameter: product ID
// second parameter [optional, unlimited by default]: max quantity of products coupon will be applied to (if buying multiple)
$coupon->addObject(3, 1);
// Action, only 'discount' for now
// second parameter either percentage ('10%') or absolute dollar value ('20')
$coupon->setAction('discount', '10%');
// Add coupon
$coupon->add();
} catch (\Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
return;
}
if (0) {
// DELETE COUPON
$warehouse = new Warehouse();
try {
$warehouse->deleteCoupon('couponcode3');
} catch (\Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
return;
}
if (0) {
// CREATE NEW COURSE
include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Course.php';
$course = new Course();
$course->setName('Name of the course');
$course->setDescription('Short description');
$course->setPrice(12.0);
$course->addToCollection('courses');
// Membership model: membership duration period (must me in MySQL date format: 1 DAY, 2 MONTH, 3 YEAR...)
$course->setTimeToLive('1 YEAR');
// Course alias id
$course->setCourseId('nanoscaletransistors');
try {
// Returns object with values, pId is the new product ID to link to
$info = $course->add();
//print_r($info);
} catch (\Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
return;
}
if (0) {
// GET EXISTING COURSE, modify it and save
$warehouse = new Warehouse();
try {
// Get course by pID returned with $course->add() above
$course = $warehouse->getCourse(1);
$course->setName('Renamed');
$course->setDescription('New description');
$course->setPrice(55.22);
$course->setTimeToLive('10 YEAR');
$course->update();
} catch (\Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
return;
}
if (0) {
// UPDATE COURSE by recreating it
include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCourse.php';
$course = new Course();
$course->setName('Operations Management 104');
$course->setDescription('Operations Management 104 is some kind of test course for now...');
$course->setPrice(13.05);
$course->setCourseId(5);
// Existing course ID (pID returned with $course->add() when the course was created). Must be set to be able to update.
$course->setId(1023);
try {
$info = $course->update();
//print_r($info);
} catch (\Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
return;
}
if (0) {
// DELETE COURSE
//.........这里部分代码省略.........
示例3: array
$uploadOk = 0;
}
if ($_FILES["file"]["size"] > 800000000 || $_FILES["image"]["size"] > 8000000) {
$msg .= " Course media is too large.";
$uploadOk = 0;
}
if ($courseMedFil != '') {
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
}
if ($courseImgFil != '') {
move_uploaded_file($_FILES["image"]["tmp_name"], $target_Image);
}
if ($uploadOk == 0) {
$msg = "Sorry, your course media was not uploaded. ERROR: " . $msg;
$json = array("status" => 0, "msg" => $msg);
$dbObj->close();
//Close Database Connection
header('Content-type: application/json');
echo json_encode($json);
} else {
echo $courseObj->add();
}
} else {
$json = array("status" => 0, "msg" => $errorArr);
$dbObj->close();
//Close Database Connection
header('Content-type: application/json');
echo json_encode($json);
}
}
}
示例4: Validate
<?php
require_once '../core/init.php';
if (Input::exists('post') && privilege() != NULL) {
$validate = new Validate();
$validation = $validate->check($_POST, array('coursecode' => array('required' => true), 'coursename' => array('required' => true), 'department' => array('required' => true)));
if ($validate->passed()) {
$dep = new Course();
$add = $dep->add(Input::get('coursecode'), Input::get('coursename'), Input::get('department'), Input::get('credit'));
if ($add == 3) {
echo '<div class="alert alert-danger alert-dismissible" role="alert">';
echo '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>';
echo 'Sorry, you don\'t have privilege to create department.';
echo '</div>';
} else {
if ($add == 2) {
echo '<div class="alert alert-danger alert-dismissible" role="alert">';
echo '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>';
echo Input::get('coursename') . ' Course already exists.';
echo '</div>';
} else {
if ($add == 1) {
echo '<div class="alert alert-success alert-dismissible" role="alert">';
echo '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>';
echo 'Course created successfully';
echo '</div>';
} else {
if ($add == 0) {
echo '<div class="alert alert-danger alert-dismissible" role="alert">';
echo '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>';
echo 'Temporary Error!';