save() is undefined in CActiveRecord model?

I have a problem calling save() or update() in a model when I call these inside another models actionDelete.

Specifically this:


public function actionDelete($id)

    {


        $model = $this->loadModel($id);


        if (Yii::app()->request->isPostRequest) {

            // we only allow deletion via POST request


            $visits = $model->visits;


            if (count($visits) > 0) {


                foreach ($visits as $visit) {


                    $visit->peopleCount = $visit->peopleCount - 1;

                    $visit.save();

                }

            }


            PersonVisit::model()->deleteAll('personId=:personId', array(':personId'=>$id));


            $model->delete();


            // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser

            if (!isset($_GET['ajax']))

                $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));

        }

        else

            throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');

    }



… fails in $visit->save() with the error message in the description…

I have used save() and update() in the same controller for the Visit model w/o any problems. What’s special about delete action?

Nothing, you’re using “.” instead of “->”:

$visit.save();

Oh, well. What a stupid mistake! Thanks for pointing out.