Question

I have had a look around the web and can't find a good explanation.

Using Gii I generate models. I was wondering how I can get the generator to also add a custom method to all of my models I generate? I want to add a method where I pass it the result of a "->queryAll()" and it maps it to itself for me.

Thanks in advance

Was it helpful?

Solution

You should read this :

http://www.yiiframework.com/doc/guide/1.1/en/topics.gii#extending-gii

Gii can be extended in two ways: customizing the code templates of the existing code generators, and writing new code generators.

But a proper way for adding a custom method to all your models is to extends CActiveRecord, and modify Gii template accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top