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


PHP Course::findById方法代码示例

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


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

示例1: process

 public function process($get, $post)
 {
     $this->pageData["Title"] = "Home";
     // Select all of the courses that this user is already added or ignored
     $query = new Query('action');
     $result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId'])));
     $idsAlreadyAdded = array();
     foreach ($result as $action) {
         array_push($idsAlreadyAdded, $action->get('course_id'));
     }
     // Generate all of the courses (for testing)
     $allCourses = array();
     $query = new Query('courses');
     $result = $query->select('*', '', array('number', 'ASC'), 20, false);
     while ($row = mysqli_fetch_array($result)) {
         try {
             $course = new Course();
             $course->findById($row['id']);
             if (!in_array($course->get('id'), $idsAlreadyAdded)) {
                 // Check that this course has not been added by the user yet
                 array_push($allCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number'), 'description' => strlen($course->get('description')) == 0 ? 'No description' : $course->get('description')));
             }
         } catch (Exception $e) {
         }
     }
     $this->pageData['allCourses'] = $allCourses;
     // Select all of the courses that this user is already added
     $query = new Query('action');
     $result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId']), array('choice', '=', 0)));
     $idsAlreadyAdded = array();
     foreach ($result as $action) {
         array_push($idsAlreadyAdded, $action->get('course_id'));
     }
     // Get all of the courses in this user's session
     $usersCourses = array();
     foreach ($idsAlreadyAdded as $courseId) {
         try {
             $course = new Course();
             $course->findById($courseId);
             array_push($usersCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number')));
         } catch (Exception $e) {
         }
     }
     $this->pageData['usersCourses'] = $usersCourses;
 }
开发者ID:bennyty,项目名称:suggestr,代码行数:45,代码来源:Home_.php

示例2: isset

<?php

$id = isset($vars[1]) ? $vars[1] : null;
$object = Course::findById($id);
if (is_null($object)) {
    HTML::forward('core/404');
}
// handle form submission
if (isset($_POST['submit'])) {
    $error_flag = false;
    /// validation
    // validation for $title
    $title = isset($_POST["title"]) ? strip_tags($_POST["title"]) : null;
    if (empty($title)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "title is required.", "zh" => "请填写title"))));
        $error_flag = true;
    }
    // validation for $country_id
    $country_id = isset($_POST["country_id"]) ? strip_tags($_POST["country_id"]) : null;
    if (empty($country_id)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "country_id is required.", "zh" => "请填写country_id"))));
        $error_flag = true;
    }
    // validation for $content
    $content = isset($_POST["content"]) ? $_POST["content"] : null;
    if (empty($content)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "content is required.", "zh" => "请填写content"))));
        $error_flag = true;
    }
    // validation for $url
    $url = isset($_POST["url"]) ? strip_tags($_POST["url"]) : null;
开发者ID:jeffreycai,项目名称:ct21,代码行数:31,代码来源:course_edit.php

示例3: getClassNameById

 function getClassNameById($id)
 {
     $result = new Course();
     $result->findById($id);
     return $result->get('name');
 }
开发者ID:bennyty,项目名称:suggestr,代码行数:6,代码来源:suggestions.php

示例4: isset

<?php

$id = isset($vars[1]) ? $vars[1] : null;
$course = Course::findById($id);
$country = $course->getCountry();
if (is_null($course)) {
    dispatch('site/404');
    exit;
}
$html = new HTML();
$html->renderOut('site/components/html_header', array('title' => 'Course - ' . $course->getTitle(), 'body_class' => 'single single-ib_educator_course has-toolbar'));
$html->output('<div id="page-container">');
//$html->renderOut('site/components/toptoolbar');
$html->renderOut('site/components/header');
$html->renderOut('site/course', array('breadcrumb' => $html->render('site/components/breadcrumb', array('items' => array('Home' => uri(''), $country->getName() => uri('country/' . $country->getId()), $course->getTitle() => false))), 'course' => $course, 'sidebar_right' => $html->render('site/components/sidebar_right', array('blocks' => array($html->render('site/components/sidebar_block_courses', array('course' => $course)), $html->render('site/components/sidebar_block_recent_news'), $html->render('site/components/sidebar_block_apply'))))));
$html->renderOut('site/components/footer');
$html->output('</div>');
$html->renderOut('site/components/page_footer');
$html->renderOut('site/components/html_footer');
开发者ID:jeffreycai,项目名称:ct21,代码行数:19,代码来源:course.php

示例5: process

 public function process($get, $post)
 {
     $this->pageData["Title"] = "Home";
     //Generate the data from mysql.
     //NEED TO FIGURE OUT WHY COOKIE IS NOT WORKING. HERE I SET IT manually.
     $_COOKIE['sessionId'] = rand(880, 925);
     //Something wrong when no classes are taken by a given session.
     //I'll try to fix that someday.
     $Data = new Database();
     //Setting up student
     //Replace with $session_id. The cookie doesn't work for me(Lucien) though...
     //$session = 912;//intval($_COOKIE['sessionId']);
     //echo "num: ".$session;
     $student = $Data->getStudent($_COOKIE['sessionId']);
     $studentCourses = $student->getTaken();
     //echo " Session: ".$student->getId()." major: ".$student->getMajor()." year: ".$student->getYear();
     foreach ($studentCourses as $course) {
         $result = new Course();
         $result->findById($course);
         //echo "<h4>".$result->get('name')."<h4>";
     }
     //Here's the array of courses generated by the Jaccard index.
     $JaccardCourses = $Data->getSuggestedCourses($studentCourses);
     // Select all of the courses that this user is already added or ignored
     $query = new Query('action');
     $result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId'])));
     $idsAlreadyAdded = array();
     foreach ($result as $action) {
         array_push($idsAlreadyAdded, $action->get('course_id'));
     }
     // Generate all of the courses (for testing)
     //Get list of predicted courses from Python.
     $predClasses = $this->predictClasses();
     $allCourses = array();
     $query = new Query('courses');
     //Adding predicted courses to the $allCourses array.
     /*foreach($predClasses as $class){
     			$result = new Course();
     			$result->findById($class['id']);
     			array_push($allCourses,$result);
     		}*/
     //Grabs the Id's from the Jaccard Array and
     foreach ($JaccardCourses as $class => $score) {
         $result = new Course();
         $result->findById($class);
         array_push($allCourses, $result);
     }
     //$allcourses only contains the course id's
     //Create new array containing all the course details based on what is in Allcourses.
     $allNewCourses = array();
     foreach ($allCourses as $course) {
         try {
             if (!in_array($course->get('id'), $idsAlreadyAdded)) {
                 // Check that this course has not been added by the user yet
                 array_push($allNewCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number'), 'description' => strlen($course->get('description')) == 0 ? 'No description' : $course->get('description')));
             }
         } catch (Exception $e) {
         }
     }
     //Populate webpage with all the different courses that were predicted.
     $this->pageData['allCourses'] = $allNewCourses;
     /*
     		IMPORTANT NODE
     */
     //////////
     // Select all of the courses that this user is already added
     $query = new Query('action');
     $result = $query->select('*', array(array('session_id', '=', $_COOKIE['sessionId']), array('choice', '=', 1)));
     ///is 0 in leo's version, 1 in my old database. we need to sort that shit.
     $idsAlreadyAdded = array();
     foreach ($result as $action) {
         array_push($idsAlreadyAdded, $action->get('course_id'));
     }
     // Get all of the courses in this user's session
     $usersCourses = array();
     foreach ($idsAlreadyAdded as $courseId) {
         try {
             $course = new Course();
             $course->findById($courseId);
             array_push($usersCourses, array('id' => $course->get('id'), 'name' => ucwords(strtolower($course->get('name'))), 'department_id' => $course->get('department_id'), 'number' => $course->get('number')));
         } catch (Exception $e) {
         }
     }
     $this->pageData['usersCourses'] = $usersCourses;
     //Pushes all the new courses to the view.
 }
开发者ID:bennyty,项目名称:suggestr,代码行数:86,代码来源:home.php


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