javedboqo
(Javi Hunzai)
September 7, 2014, 10:33am
1
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
{
....
}
alirz23
(Ali Raza)
September 7, 2014, 5:20pm
2
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 ...
}
}
}
javedboqo
(Javi Hunzai)
September 8, 2014, 6:37am
3
alirz23:
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.