I've recently been introduced to the concept of Saving the model that I've updated. In this case, I have created a function called incrementPayList which takes in the id of a list and the increments it by one.
This is the code for the function in the paylist model
public function incrementPayList($id) 
{
    $results = Recipient::model()->findAll(array("condition"=>"list_id = $id"));
    $count = count ( $results );
    $this->num_indv = $count + 1;         
}
Now in the recipient controller, I am calling this function. The recipient holds all of the individuals who are connected to a certain payList
 */
public function actionCreate($id)
{
    $model=new Recipient;
    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);
    if(isset($_POST['Recipient']))
    {
        $model->attributes=$_POST['Recipient'];
        Paylist::model()->incrementPayList($id);
        if($model->save())
        {
            $this->redirect(array('view','id'=>$model->id));
        }
    }
    $this->render('create',array(
        'model'=>$model,
        'id'=>$id
    ));
}
I know that the $count returns the correct number - but it is not saving that count in the field num_indv. I have an inkling that this is because I am not saving the new PayList model. However, how/where should I do this? Should I do it inside the function itself? Or should I do it in the controller? But, if I do it in the controller, I can't simply use $model->save() because it is not the same model. 
 
     
     
     
    