peach
(Nospam)
October 21, 2009, 9:31am
1
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?
Thanks
narkomanC
(Narkomanc)
October 21, 2009, 10:41am
2
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
rickgrana
(Ricardo Grana)
October 21, 2009, 1:33pm
3
You can extend as narkomanC said.
Then, you must put your base class at ‘extensions’ dir.
peach
(Nospam)
October 21, 2009, 2:46pm
4
ok now I’ve got class JsonAR defined in extensions/folder/JsonAR.php
and in main.php I’ve got
'import'=>array(...,'application.folder.*')
and I get:
include(JsonAR.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
peach
(Nospam)
October 21, 2009, 2:48pm
5
ok now I’ve got class JsonAR defined in extensions/folder/JsonAR.php
and in main.php I’ve got
'import'=>array(...,'application.folder.*')
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:
'import'=>array(...,'application.extensions.folder.*')
rickgrana
(Ricardo Grana)
October 22, 2009, 2:12pm
6
SInce 1.0.8 version you can use just ‘ext’ instead of ‘application.extensions’
peach
(Nospam)
October 22, 2009, 3:48pm
7
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.