Extend models with search class to a different namespace

Hi all,

this is my situation: I have two models:


app\models\Service

app\models\ServiceSearch

I want to extend them into a new module, so I’ll have:


app\modules\archive\Service extends app\models\Service

app\modules\archive\ServiceSearch extends app\models\ServiceSearch

The problem is the search method into [font="Lucida Console"]app\models\ServiceSearch[/font] call [font="Lucida Console"]Service::find()[/font] that refers to [font="Lucida Console"]app\models\Service[/font]. Is there a way to make the search method call [font="Lucida Console"]app\modules\archive\Service[/font]?

My purpose is to create an archive module that use the same models but on a different database, so I would extend my existing models and change only the getDB method.

Thanks.

It depends on how this class is written.

You can always override the search method as a last resort.

The base class is the one generated by Gii. The search method hasn’t been modified.

Yes, I could, but I will override the method as is. I wonder if there is a better solution.