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


PHP Course::findOne方法代码示例

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


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

示例1: findModel

 protected function findModel($id)
 {
     if (($model = Course::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:janwillemm,项目名称:sa-matcher,代码行数:8,代码来源:CourseController.php

示例2: actionRegister

 public function actionRegister($co = null, $cl = null)
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post())) {
         $model->course_id = $co;
         $model->classid = $cl;
         $model->created_dt = date('Y-m-d H:i:s');
         $model->save();
         return $this->redirect(['success']);
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (!empty($co)) {
             $courselist = Course::findOne($co);
         }
         return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
     }
 }
开发者ID:kaweesak,项目名称:arit_training,代码行数:17,代码来源:StudentController.php

示例3:

<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\User;
use app\models\Course;
/* @var $this yii\web\View */
/* @var $model app\models\UserHasCourse */
$this->title = $model->user_id;
$this->params['breadcrumbs'][] = ['label' => 'User Has Courses', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-has-course-view">
    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'User', 'value' => User::findOne($model->user_id)->first_name . ' ' . User::findOne($model->user_id)->last_name . ' ( ' . User::findOne($model->user_id)->username . ' )'], ['label' => 'Course', 'value' => Course::findOne($model->course_id)->code . ' ( ' . Course::findOne($model->course_id)->name . ' )']]]);
?>

    <p>
        <?php 
echo Html::a('Update', ['update', 'user_id' => $model->user_id, 'course_id' => $model->course_id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'user_id' => $model->user_id, 'course_id' => $model->course_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>
</div>
开发者ID:santonil2003,项目名称:yii,代码行数:26,代码来源:view.php

示例4: _pickStudentAssistant

 /**
  * Show the student assistant picking page
  *
  * @param $model
  * @param $course_id
  * @return string
  */
 private function _pickStudentAssistant($model, $course_id)
 {
     // Fetch all students assistants
     $course = Course::findOne($course_id);
     return $this->render('pickSA', ['model' => $model, 'sas' => $course->studentAssistants]);
 }
开发者ID:janwillemm,项目名称:sa-matcher,代码行数:13,代码来源:ReviewController.php


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