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


PHP Student::setAttributes方法代码示例

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


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

示例1: actionAdmin

 public function actionAdmin()
 {
     $model = new Student('search');
     $model->unsetAttributes();
     if (isset($_GET['Student'])) {
         $model->setAttributes($_GET['Student']);
     }
     $this->render('admin', array('model' => $model));
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:9,代码来源:StudentController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Student();
     //	$this->performAjaxValidation($model, 'product-form');
     if (isset($_POST['Student'])) {
         $model->setAttributes($_POST['Student']);
         $relatedData = array('assignments' => $_POST['Student']['assignments'] === '' ? null : $_POST['Student']['assignments']);
         if ($model->saveWithRelated($relatedData)) {
             //if model was saved
             echo '<textarea>' . json_encode(array('success' => true, 'id' => $model->primaryKey)) . '</textarea>';
             Yii::app()->end();
         } else {
             echo '<textarea>' . json_encode(array('success' => false)) . '</textarea>';
             Yii::app()->end();
         }
     }
 }
开发者ID:nov072008,项目名称:yiitesting,代码行数:17,代码来源:StudentController.php

示例3: actionRegister

 public function actionRegister()
 {
     $arrayAuthRoleItems = Yii::app()->authManager->getAuthItems(2, Yii::app()->user->getId());
     $arrayKeys = array_keys($arrayAuthRoleItems);
     $role = strtolower($arrayKeys[0]);
     if ($role == 'admin' || $role == 'teacher') {
         $this->redirect('/');
     }
     $this->layout = 'dangkyhoc';
     $model = new Student();
     if (isset($_GET['cid']) && (int) $_GET['cid']) {
         $model->class_id = $_GET['cid'];
     }
     $db = Yii::app()->db;
     if (isset($_POST['Student']) && $_POST['Student']) {
         $model->setAttributes($_POST['Student']);
         $gclass = ClassGuitar::model()->findByPk($model->class_id);
         $sql = "SELECT * FROM {{student}} WHERE user_id =" . Yii::app()->user->id . " ORDER BY id DESC";
         $cmd = $db->createCommand($sql);
         $student = $cmd->queryRow();
         if ($student) {
             //                var_dump($studentơclass_id);
             $gclass2 = ClassGuitar::model()->findByPk($student['class_id']);
             if ($student['status'] == 'comp') {
                 //Hoàn thành
                 if ($gclass->tid <= $gclass2->tid) {
                     $training = Training::model()->findByPk($gclass2->tid);
                     Yii::app()->user->setFlash('error', 'Bạn đã hoàn thành một lớp thuộc khóa <b>' . $training->title . '</b>. Vui lòng đăng ký khóa học cao hơn.');
                 }
             } elseif ($student['status'] == 'reg') {
                 // Mới đăng ký
                 Yii::app()->user->setFlash('error', 'Bạn đã đăng ký học tại lớp <b>' . $gclass2->title . '</b>. Vui lòng hủy đơn đăng ký này trước khi đăng ký tham gia lớp học khác!');
             } else {
                 $center = Center::model()->findByPk($gclass2->cid);
                 Yii::app()->user->setFlash('error', 'Bạn đang tham gia lớp học <b>' . $gclass2->title . '</b> tại cơ sở <b>' . $center->title . '</b>!');
             }
         } else {
         }
         if (!Yii::app()->user->hasFlash('error') && $model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 Yii::app()->user->setFlash('success', 'Bạn đã đăng ký lớp học thành công. LNT sẽ sớm liên lạc lại với bạn.');
             }
         }
     } else {
         $oldStudent = Student::model()->find('user_id=' . Yii::app()->user->id);
         if ($oldStudent) {
             $model->name = $oldStudent->name;
             $model->email = $oldStudent->email;
             $model->tel = $oldStudent->tel;
             $model->birthday = $oldStudent->birthday;
         }
     }
     $this->render('register', array('model' => $model));
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:56,代码来源:TrainingController.php

示例4: prepare_dataproviders

 /**
  *  Prepares dataproviders for models and jstree open nodes.
  * @return  array  Contains the dataproviders for the models,open nodes for the tree and the model to search for.
  * @since 1.0
  */
 private function prepare_dataproviders()
 {
     //create an array open_nodes with the ids of the nodes that we want to be initially open
     //when the tree is loaded.Modify this to suit your needs.Here,we open all nodes on load.
     $categories = Classroom::model()->findAll(array('order' => 'lft'));
     $identifiers = array();
     foreach ($categories as $n => $category) {
         $identifiers[] = "'" . 'node_' . $category->id . "'";
     }
     $open_nodes = implode(',', $identifiers);
     $cat_dataProvider = new CActiveDataProvider('Classroom');
     $prod_criteria = new CDbCriteria();
     $prod_criteria->with = array('assignments' => array('on' => 'assignments.id=:cat_id', 'together' => true, 'joinType' => 'INNER JOIN', 'params' => array(':cat_id' => $_GET['cat_id'])));
     //for search
     $model = new Student('search');
     $model->unsetAttributes();
     if (isset($_GET['Student'])) {
         //if searching
         $model->setAttributes($_GET['Student']);
         $search_criteria = $model->searchCriteria();
         $prod_criteria->mergeWith($search_criteria);
     }
     $prod_dataProvider = new CActiveDataProvider('Student', array('criteria' => $prod_criteria, 'pagination' => array('pageSize' => self::PAGING_SIZE_CAT)));
     return array('cat_provider' => $cat_dataProvider, 'prod_provider' => $prod_dataProvider, 'open_nodes' => $open_nodes, 'model' => $model);
 }
开发者ID:nov072008,项目名称:yiitesting,代码行数:30,代码来源:ClassroomController.php


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