Filter Model By Pk

Hi All

When I try to filter a view with either findAllByPk or just using the array as a search filter on the ID I get FatalErrors

Here’s my code, neither of the commented code works:




 public function actionDashboard()

    {


        $model = Complexs::model()->findAllByPk(Yii::app()->session['cID']);

        //$model = Complexs::model(Yii::app()->session['cID']);

        //$model->ID=Yii::app()->session['cID'];

        //$model->search();

        $this->render('dashboard',array(

            'model'=>$model,

        ));

    }



there is either findAllByPk() or findByPk() first one returns array of objects, second one - single object (there is difference on how you use returned data)

Yes I have been a dumb ass, I forgot to unserialize my $array value I’m getting from a session variable, it works now:




    public function actionDashboard()

    {

        $arr = Yii::app()->session['cID'];

        $model = Complexs::model();

        $model->ID=$arr;

        $model->search();

        $this->render('dashboard',array(

            'model'=>$model,

        ));

    }



thanks for quick help

your first response before you edited helped me, thanks man