当前位置: 首页>>代码示例>>PHP>>正文


PHP Course::setId方法代码示例

本文整理汇总了PHP中Course::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::setId方法的具体用法?PHP Course::setId怎么用?PHP Course::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course::setId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 public function add(Course $course)
 {
     $a = array(StudyPressDB::COL_NAME_COURSE => $course->getName(), StudyPressDB::COL_DESCRIPTION_COURSE => $course->getDescription(), StudyPressDB::COL_PICTURE_COURSE => $course->getPictureId());
     $this->_access->insert(StudyPressDB::getTableNameCourse(), $a);
     $idCourse = $this->_access->getLastInsertId();
     $course->setId($idCourse);
     $this->addCategories($idCourse, $course->getCategories());
     $this->addGroupsBP($idCourse, $course->getGroupsBP());
     $this->addUsers($idCourse, $course->getAuthors());
     $this->post($course);
     return $idCourse;
 }
开发者ID:Cossumo,项目名称:studypress,代码行数:12,代码来源:CourseManager.class.php

示例2: addCourse

 /**
  * Adds a course.
  *
  * Called when this component receives an HTTP POST request to
  * /course(/).
  * The request body should contain a JSON object representing the course's
  * attributes.
  */
 public function addCourse($callName, $input, $params = array())
 {
     $positive = function ($input) {
         // sets the new auto-increment id
         $id = 0;
         $queryResult = $input[count($input) - 1];
         $resp = $queryResult->getResponse();
         if (isset($resp[0]['@a'])) {
             $id = $resp[0]['@a'];
         }
         // sets the new auto-increment id
         $obj = new Course();
         $obj->setId($input[0]->getInsertId() == 0 ? $id : $input[0]->getInsertId());
         return array("status" => 201, "content" => $obj);
     };
     return $this->_component->callSqlTemplate('out2', dirname(__FILE__) . '/Sql/AddCourse.sql', array('values' => $input->getInsertData(), 'in' => $input), 201, $positive, array(), 'Model::isProblem', array(new Course()));
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:25,代码来源:DBCourse.php

示例3: doImport

 /**
  * Start browsing the directory and register files
  *
  * @return       Exception code = 400 if directory non-existent
  *               An array containing list of non-imported files if successful
  */
 public function doImport()
 {
     if (!file_exists($this->_dir)) {
         throw new Exception("directory non-existent", 400);
     }
     $errArr = array();
     $handler = opendir($this->_dir);
     // TODO: does not do recrusive listing, do we need that?
     while (false !== ($file = readdir($handler))) {
         if ($file != '.' && $file != '..') {
             $err = false;
             $pos = strrpos($file, '.');
             $fileName = strtoupper(substr($file, 0, $pos));
             $token = strtok($fileName, '_');
             $counter = 0;
             while (false !== $token) {
                 switch ($counter) {
                     case 0:
                         if (strlen($token) != 7) {
                             $err = true;
                         }
                         $rawCourseCode = $token;
                         break;
                     case 1:
                         if ($token != substr($this->_year, 0, 4)) {
                             $err = true;
                         }
                         break;
                     case 2:
                         if ($token != "EXAM") {
                             if (substr($token, 0, 5) == "EXAM(") {
                                 // name could have the following syntax: AER205S_2009_EXAM(2).pdf
                                 $count = strtok($token, '(');
                                 $count = strtok('(');
                                 $count = strtok($count, ')');
                                 if ($count === false || !is_numeric($count)) {
                                     $err = true;
                                 }
                             } else {
                                 $err = true;
                             }
                         }
                         break;
                 }
                 $token = strtok("_");
                 $counter++;
             }
             if ($counter != 3 || $err) {
                 $err = true;
             } else {
                 // assume course code is 7 chars in length with the last char being either S, F or Y
                 $part1 = substr($rawCourseCode, 0, 6);
                 //e.g. AER205
                 $part2 = substr($rawCourseCode, 6, 1);
                 //e.g. F
                 switch ($part2) {
                     case "F":
                     case "S":
                         $courseCode = $part1 . "H1";
                         $descr = $part1 . " " . $this->_year . " Official Exam" . (isset($count) ? ' (' . $count . ')' : '');
                         break;
                     case "Y":
                         $courseCode = $part1 . "Y1";
                         $descr = $part1 . " " . $this->_year . " Official Exam" . (isset($count) ? ' (' . $count . ')' : '');
                         break;
                     default:
                         $err = true;
                         break;
                 }
                 if (!$err) {
                     $conn = Propel::getConnection();
                     // check if we have exam of this descr already
                     $examArr = ExamPeer::getExamsForYearAndCourseId($courseCode, $this->_year, $conn);
                     foreach ($examArr as $ex) {
                         if ($ex->getType() == EnumItemPeer::EXAM && $ex->getDescr() == $descr) {
                             $err = true;
                             break;
                         }
                     }
                     if (!$err) {
                         // first check if course exists
                         $course = CoursePeer::retrieveByPK($courseCode, $conn);
                         if (!isset($course)) {
                             $course = new Course();
                             //$course->setDeptId(substr($courseCode, 0, 3));
                             $course->setDescr($courseCode);
                             $course->setIsEng(1);
                             $course->setId($courseCode);
                             $dept = DepartmentPeer::retrieveByPK(substr($courseCode, 0, 3), $conn);
                             if (!isset($dept)) {
                                 $dept = new Department();
                                 $dept->setId(substr($courseCode, 0, 3));
                                 $dept->setDescr(substr($courseCode, 0, 3));
                                 $dept->save($conn);
//.........这里部分代码省略.........
开发者ID:jasonkouoft,项目名称:SkuleCourses,代码行数:101,代码来源:importLogicBulkExams.class.php

示例4: testSetId

 function testSetId()
 {
     //Arrange
     $name = "Math";
     $course_num = "101";
     $id = 1;
     $test_course = new Course($name, $course_num, $id);
     //Act
     $test_course->setId(2);
     $result = $test_course->getId();
     //Assert
     $this->assertEquals(2, $result);
 }
开发者ID:jlbethel,项目名称:Registrar-switch,代码行数:13,代码来源:CourseTest.php

示例5: Course

$s->load();
echo $s->getName() . "\n";
$courses = $s->getCourses();
foreach ($courses as $c) {
    echo $c->getDescription() . "\n";
    $course = $c;
}
$s->deleteCourses($course);
Hypersistence::commit();
$s->load(true);
$courses = $s->getCourses();
foreach ($courses as $c) {
    echo $c->getDescription() . "\n";
}
$c = new Course();
$c->setId(1);
$c->load();
echo $c->getDescription() . "\n";
$students = $c->getStudents();
foreach ($students as $s) {
    echo $s->getName() . "\n";
}
//SEARCH
$p = new Person();
$p->setName('Mat');
$search = $p->search();
$search->orderBy('name');
$list = $search->execute();
foreach ($list as $p) {
    echo $p->getName() . "\n";
}
开发者ID:mateusfornari,项目名称:hypersistence-alpha,代码行数:31,代码来源:index.php

示例6: saveToDatabase

 public function saveToDatabase()
 {
     if (isset($this->_infoArr) && isset($this->_mappingArr)) {
         $err = "";
         $conn = Propel::getConnection();
         $dt = date("Y-m-d, H:i:s");
         $len = count($this->_infoArr);
         for ($i = 0; $i < $len; $i++) {
             $course = CoursePeer::retrieveByPK($this->_infoArr[$i]["courseCode"]);
             if (!isset($course)) {
                 // new course found, save to db
                 $course = new Course();
                 $course->setDescr($this->_infoArr[$i]["courseName"]);
                 $course->setIsEng(1);
                 $course->setDeptId(substr($this->_infoArr[$i]["courseCode"], 0, 3));
                 $course->setId($this->_infoArr[$i]["courseCode"]);
                 $course->save($conn);
             } elseif ($course->getDescr() == $course->getId()) {
                 // exam importer registers course description as course id
                 // if we encounter this situation, amend it with the proper description
                 $course->setDescr($this->_infoArr[$i]["courseName"]);
                 $course->save($conn);
             }
             try {
                 $instr = InstructorPeer::findInstructorByName($this->_infoArr[$i]["instrFirstName"], $this->_infoArr[$i]["instrLastName"], $conn);
             } catch (Exception $e) {
                 if ($e->getCode() == 1) {
                     // no instructor found
                     $instr = new Instructor();
                     $instr->setFirstName($this->_infoArr[$i]["instrFirstName"]);
                     $instr->setLastName($this->_infoArr[$i]["instrLastName"]);
                     $instr->setDeptId($course->getDeptId());
                     $instr->save($conn);
                 } else {
                     // TODO: big problem, duplicate instructors found
                     // log error and move on
                     continue;
                 }
             }
             // create CourseInstructorAssociation if it doesn't exist
             try {
                 $assoc = CourseInstructorAssociationPeer::findForYearAndInstructorIdAndCourseId($this->_year, $course->getId(), $instr->getId(), $conn);
             } catch (Exception $e) {
                 if ($e->getCode() == 1) {
                     // create new object
                     $assoc = new CourseInstructorAssociation();
                     $assoc->setYear($this->_year);
                     $assoc->setCourseId($course->getId());
                     $assoc->setInstructorId($instr->getId());
                     $assoc->save($conn);
                 } else {
                     // TODO: big problem, duplicate assocs found
                     // log error and move on
                     continue;
                 }
             }
             // we can now save the real rating data
             $ratingArr = $this->_ratingArr[$i];
             foreach ($ratingArr as $fieldId => $data) {
                 foreach ($data as $rating => $number) {
                     $ratingObj = new AutoCourseRating();
                     $ratingObj->setFieldId($fieldId);
                     $ratingObj->setRating($rating);
                     $ratingObj->setNumber($number);
                     $ratingObj->setImportDt($dt);
                     $ratingObj->setCourseInsId($assoc->getId());
                     $ratingObj->save();
                 }
             }
         }
     } else {
         throw new Exception("readCsv method has not been called.");
     }
 }
开发者ID:jasonkouoft,项目名称:SkuleCourses,代码行数:74,代码来源:importLogicRatings.class.php

示例7: 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
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:test.php


注:本文中的Course::setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。