本文整理汇总了PHP中Course::getCourseId方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::getCourseId方法的具体用法?PHP Course::getCourseId怎么用?PHP Course::getCourseId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::getCourseId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a new entry.
* @param User $creator The creator of the entry.
* @param type $title The title of the entry.
* @param type $description The entry description.
* @return Entry
* @throws Exception
*/
public static function create(User $creator, Course $course, $title, $description)
{
// Insert it into the database
$query = Database::connection()->prepare('INSERT INTO entry (courseid, created_at, created_by, display_at, title, description)' . ' VALUES (?, ?, ?, ?, ?, ?)');
$query->bindValue(1, $course->getCourseId(), PDO::PARAM_INT);
$query->bindValue(2, time(), PDO::PARAM_INT);
$query->bindValue(3, $creator->getUserId(), PDO::PARAM_INT);
$query->bindValue(4, time(), PDO::PARAM_INT);
$query->bindValue(5, $title, PDO::PARAM_STR);
$query->bindValue(6, $description, PDO::PARAM_STR);
if (!$query->execute()) {
throw new Exception('Entry could not be created in the database.');
}
// Get the course from the last insert id
$entry = self::fromId(Database::connection()->lastInsertId());
// Sync the course
$entry->changed();
// Return the course
return $entry;
}
示例2: course
/**
* Adds a course to the sync queue.
* @param Course $course The course to add.
*/
public static function course(Course $course)
{
self::$coursesToSync[$course->getCourseId()] = $course;
}
示例3: testFind
function testFind()
{
//arrange
$course_name = "Chemistry";
$course_id = 1;
$course_number = "1000";
$test_course = new Course($course_name, $course_number, $course_id);
$test_course->save();
$course_name2 = "Underwater Basketweaving";
$course_id2 = 2;
$course_number2 = "2531";
$test_course2 = new Course($course_name2, $course_number2, $course_id2);
$test_course2->save();
//act
$result = Course::find($test_course->getCourseId());
//assert
$this->assertEquals($test_course, $result);
}