Yii Framework Forum: Save Model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Save Model Rate Topic: -----

#1 User is offline   Javed Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 25-October 11

Posted 07 September 2014 - 05:33 AM

hi
I need to save model from another controller. I used following code but it is not saving changes in database.
class FeePaidBulkController extends Controller
{
...
public function actionDoBulkPayment() {
 FeePaid::model()->student_id=$iStudentId;
 FeePaid::model()->fee_structure_id=$iFeeStructureId;
 if(FeePaid::model()->save())	{
 }
}
...
}

class FeepaidController extends Controller
{
....
}

Javed Iqbal

Web Developer
syntecX Solution
skype:javedboqo
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,498
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 07 September 2014 - 12:20 PM

create a new instance of the FeePaid like so

<?php

class FeePaidBulkController extends Controller
{
	public function actionDoBulkPayment() {
		$feePaid = new FeePaid;
		$feePaid->student_id=$iStudentId;
		$feePaid->fee_structure_id=$iFeeStructureId;
		if($feePaid->save()){
			// do stuff ...
		}
 	}

}

0

#3 User is offline   Javed Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 25-October 11

Posted 08 September 2014 - 01:37 AM

View Postalirz23, on 07 September 2014 - 12:20 PM, said:

create a new instance of the FeePaid like so

<?php

class FeePaidBulkController extends Controller
{
	public function actionDoBulkPayment() {
		$feePaid = new FeePaid;
		$feePaid->student_id=$iStudentId;
		$feePaid->fee_structure_id=$iFeeStructureId;
		if($feePaid->save()){
			// do stuff ...
		}
 	}

}




Thanks alirz23. I was not creating instance of model thats why it was not saving in db.
Javed Iqbal

Web Developer
syntecX Solution
skype:javedboqo
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users