best practice: extending ActiveRecord [solved]

Hello all,

I’m in the need to extend the ActiveRecord class to add a couple of functions needed by all my models.

At the moment I’m going to write the class file and put it in the models directory, but I don’t know if this is the way to do that. Any suggestions?

One of the things I need to do is to get all the fields that are numerical, is this possibile out of the box or I need to write my own function to parse the rules() output?


i don’t know exactly, but if i need to all my controllers some variables or functions i use my own main Controller as parent for other my controllers:

class MyBaseController extends CController

{ ...

class SomeController extends MyBaseController


so maybe you can find info about same thing with Models

You can extend as narkomanC said.

Then, you must put your base class at ‘extensions’ dir.

ok now I’ve got class JsonAR defined in extensions/folder/JsonAR.php

and in main.php I’ve got


and I get:

include(JsonAR.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

ok, nevermind

I should have wrote:


SInce 1.0.8 version you can use just ‘ext’ instead of ‘application.extensions’

good to know that… I think the cookbook needs a little bit of rework, lot of problems I’ve faced so far were supposed to be in there. imho.