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


PHP Course::save方法代码示例

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


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

示例1: store

 public static function store()
 {
     $params = $_POST;
     $course_params = array('name' => $params['name'], 'city' => $params['city']);
     $course = new Course($course_params);
     $errors = $course->errors();
     $number_of_holes = count($params) - count($course_params) - 1;
     // one hidden input for hole_count
     // Check hole validity before saving anything
     $holes = array();
     for ($hole_num = 1; $hole_num <= $number_of_holes; $hole_num++) {
         $par = $params['hole' . $hole_num];
         $hole = new Hole(array('hole_num' => $hole_num, 'par' => $par));
         $holes[] = $hole;
         $errors = array_merge($errors, $hole->errors());
     }
     if (count($errors) == 0) {
         // Course and holes were all valid
         $courseid = $course->save();
         $course->number_of_holes = count($holes);
         foreach ($holes as $hole) {
             $hole->courseid = $courseid;
             $hole->save();
         }
         Redirect::to('/course/' . $courseid, array('message' => 'Rata ja sen väylät lisätty.'));
     } else {
         View::make('course/new.html', array('errors' => $errors, 'attributes' => $params, 'hole_count' => $params['hole_count']));
     }
 }
开发者ID:rryanburton,项目名称:Tsoha-Bootstrap,代码行数:29,代码来源:course_controller.php

示例2: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCourse !== null) {
             if ($this->aCourse->isModified() || $this->aCourse->isNew()) {
                 $affectedRows += $this->aCourse->save($con);
             }
             $this->setCourse($this->aCourse);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:41,代码来源:BaseCourseMetadata.php

示例3: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aInstructor !== null) {
             if ($this->aInstructor->isModified() || $this->aInstructor->isNew()) {
                 $affectedRows += $this->aInstructor->save($con);
             }
             $this->setInstructor($this->aInstructor);
         }
         if ($this->aCourse !== null) {
             if ($this->aCourse->isModified() || $this->aCourse->isNew()) {
                 $affectedRows += $this->aCourse->save($con);
             }
             $this->setCourse($this->aCourse);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CourseInstructorAssociationPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CourseInstructorAssociationPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CourseInstructorAssociationPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collCourseRatings !== null) {
             foreach ($this->collCourseRatings as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collAutoCourseRatings !== null) {
             foreach ($this->collAutoCourseRatings as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:rafd,项目名称:SkuleCourses,代码行数:71,代码来源:BaseCourseInstructorAssociation.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Course();
     $batch = new Batch();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation(array($model, $batch));
     if (isset($_POST['Course'])) {
         $model->attributes = $_POST['Course'];
         $model->created_by = Yii::app()->user->id;
         $model->created_date = new CDbExpression('NOW()');
         if ($model->save()) {
             if (isset($_POST['Batch'])) {
                 $batch->batch_name = $_POST['Batch']['batch_name'];
                 $batch->batch_fees = $_POST['Batch']['batch_fees'];
                 $batch->course_id = $model->course_id;
                 $batch->batch_start_date = '';
                 $batch->batch_end_date = '';
                 $batch->batch_created_by = Yii::app()->user->id;
                 $batch->batch_creation_date = new CDbExpression('NOW()');
                 $batch->save(false);
             }
             $this->redirect(array('view', 'id' => $model->course_id));
         }
     }
     $this->render('create', array('model' => $model, 'batch' => $batch));
 }
开发者ID:rinodung,项目名称:EduSec3.0.0,代码行数:30,代码来源:CourseController.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Course();
     $model->scenario = 'create';
     if (isset($_POST['Course'])) {
         $model->attributes = $_POST['Course'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:jayrulez,项目名称:kcconline,代码行数:16,代码来源:CourseController.php

示例6: Course

 function test_save()
 {
     //Arrange
     $course_name = "Monster Literature";
     $course_number = "ENG304";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     //Act
     $result = Course::getAll();
     //Assert
     $this->assertEquals($test_course, $result[0]);
 }
开发者ID:kellimargaret,项目名称:University_Registrar,代码行数:12,代码来源:CourseTest.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Course();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Course'])) {
         $model->attributes = $_POST['Course'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:pyri,项目名称:yii-e-books,代码行数:17,代码来源:CourseController.php

示例8: testSave

 function testSave()
 {
     //Arrange
     $course_name = "HISTORY";
     $number = 101;
     $test_course = new Course($course_name, $number);
     //var_dump($test_course);
     //Act
     $test_course->save();
     //Assert
     $result = Course::getAll();
     $this->assertEquals($test_course, $result[0]);
 }
开发者ID:bencasalino,项目名称:registrar-afternoon,代码行数:13,代码来源:courseTest.php

示例9: Course

 function testCreate_OneToMany()
 {
     $this->_createModelAndIncludeThem('lecture', 'Lecture');
     $this->_createModelAndIncludeThem('course', 'Course');
     $course = new Course();
     $course->setTitle($course_title = 'bar');
     $course->save();
     $lecture = new Lecture();
     $lecture->setTitle($lecture_title = 'foo');
     $lecture->setCourse($course);
     $lecture->save();
     $loaded_lecture = lmbActiveRecord::findById('Lecture', $lecture->getId());
     $this->assertEqual($loaded_lecture->getTitle(), $lecture_title);
     $this->assertEqual($loaded_lecture->getCourse()->getId(), $course->getId());
     $loaded_course = lmbActiveRecord::findById('Course', $course->getId());
     $this->assertEqual($loaded_course->getLectures()->at(0)->getId(), $lecture->getId());
 }
开发者ID:snowjobgit,项目名称:limb,代码行数:17,代码来源:lmbModelConstructorTest.class.php

示例10: Course

 function test_addStudent_and_getStudents()
 {
     $name = "Western Civ";
     $number = "HST 101";
     $test_course = new Course($name, $number);
     $test_course->save();
     $name = "Chris";
     $date = "1111-11-11";
     $test_student = new Student($name, $date);
     $test_student->save();
     $name2 = "Dillon";
     $test_student2 = new Student($name2, $date);
     $test_student2->save();
     $test_course->addStudent($test_student);
     $test_course->addStudent($test_student2);
     $this->assertEquals($test_course->getStudents(), [$test_student, $test_student2]);
 }
开发者ID:austinblanchard,项目名称:university_registrar_switch,代码行数:17,代码来源:CourseTest.php

示例11: Course

 function test_addCourse_and_getCourses()
 {
     $name = "Western Civ";
     $number = "HST 101";
     $test_course = new Course($name, $number);
     $test_course->save();
     $name2 = "Remedial Math";
     $number2 = "MTH 64";
     $test_course2 = new Course($name2, $number2);
     $test_course2->save();
     $name = "Chris";
     $date = "1111-11-11";
     $test_student = new Student($name, $date);
     $test_student->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $this->assertEquals($test_student->getCourses(), [$test_course, $test_course2]);
 }
开发者ID:austinblanchard,项目名称:university_registrar_switch,代码行数:18,代码来源:StudentTest.php

示例12: save

 public function save()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $instituteId = Session::get('institute_id');
     if (!isset($instituteId)) {
         return json_encode(array('message' => 'invalid'));
     }
     $course = new Course();
     $course->institute_id = $instituteId;
     $course->name = Input::get('name');
     $course->description = Input::get('description');
     $course->status = 'active';
     $course->created_at = date('Y-m-d h:i:s');
     $course->save();
     return json_encode(array('message' => 'done'));
 }
开发者ID:ashutoshpandey,项目名称:course,代码行数:19,代码来源:CourseController.php

示例13: actionCreate

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
   		$model=new Course;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Course']))
        {

            $_POST['Course']['course_img']=$_FILES['Course']['name']['course_img'];
            $model->attributes=$_POST['Course'];
            $model->logo=$_FILES['Course'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->course_ID));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
开发者ID:nico13051995,项目名称:IntITA,代码行数:25,代码来源:CoursemanageController.php

示例14: store

 /**
  * Attempts to save new course and redirect to the newly created course.
  */
 public static function store()
 {
     $player = self::get_user_logged_in();
     if (!$player) {
         View::make('player/login.html', array('error' => 'Vain kirjautuneet käyttäjät voivat lisätä ratoja.'));
     }
     $params = $_POST;
     $params['url'] = self::fix_url($params['url']);
     $params['mapLink'] = self::fix_url($params['mapLink']);
     $attributes = array('name' => $params['name'], 'description' => $params['description'], 'address' => $params['address'], 'mapLink' => $params['mapLink'], 'url' => $params['url']);
     $course = new Course($attributes);
     $errors = $course->errors();
     if (count($errors) == 0) {
         $course->save();
         Hole::create_holes($params['holes'], $course->id);
         Moderator::add_as_moderator($course->id, $player->id);
         Redirect::to('/course/' . $course->id . '/edit', array('message' => 'Rata lisätty, täydennä vielä väylien tiedot.'));
     } else {
         View::make('course/new.html', array('errors' => $errors, 'attributes' => $attributes));
     }
 }
开发者ID:neodyymi,项目名称:Tsoha-Bootstrap,代码行数:24,代码来源:course_controller.php

示例15: actionCreate

 public function actionCreate()
 {
     if (!Yii::app()->user->getId()) {
         Yii::app()->user->loginRequired();
     }
     $model = new Course();
     if ($_POST['Course']) {
         $time_area = '';
         if ($_POST['Course']['time_area']) {
             $time_area = serialize($_POST['Course']['time_area']);
         }
         $_POST['Course']['time_area'] = $time_area;
         $model->attributes = $_POST['Course'];
         if ($model->validate() && $model->save()) {
             Yii::app()->user->setFlash('course', '创建成功');
             $this->redirect(array('course/index'));
         }
     }
     $stores = Store::model()->getName();
     $this->render('create', ['model' => $model, 'stores' => $stores]);
 }
开发者ID:kl0428,项目名称:admin,代码行数:21,代码来源:CourseController.php


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