Two Different Functions

Right, I figured I would simply have a couple of functions which do almost the same thing, but provide me with different results, problem is, they do exactly the same thing when called. Only the Search function works.





    public function search() {


        $criteria = new CDbCriteria;


        $criteria->compare('id', $this->id);

        $criteria->compare('login', $this->login, true);

        $criteria->compare('contact_email', $this->contact_email, true);

        $criteria->compare('first_name', $this->first_name, true);

etc etc etc

        $criteria->compare('created_at', $this->created_at, true);


        return new CActiveDataProvider(get_class($this), array(

                    'criteria' => $criteria,

                    'pagination' => array(

                        'PageSize' => 25

                    ),

                    'sort' => array(

                        'defaultOrder' => 'last_request DESC',

                    ),

                ));

    }




	    public function statistics() {


        $criteria = new CDbCriteria;


        $criteria->compare('login', $this->login, true);

        $criteria->compare('contact_email', $this->contact_email, true);

        $criteria->compare('first_name', $this->first_name, true);

        $criteria->compare('last_notified', $this->last_notified, true);


        return new CActiveDataProvider(get_class($this), array(

                    'criteria' => $criteria,

                    'pagination' => array(

                        'PageSize' => 25

                    ),

                    'sort' => array(

                        'defaultOrder' => 'last_request DESC',

                    ),

                ));

    }



Is this a Tip, a Snippet or a Tutorial?

looks like crap

Both functions return the same values, yet each is called and rendered on a different page.

I would say that is crap.

Can you share the view code?

Also controller code. I think both should work…

if you use CGridView in view, define the dataProvider like this:


'dataProvider'=>$model->statistics(),

[color="#006400"]/* moved to General Discussion */[/color]