[eluser]Michael Ekoka[/eluser]
Hi stijn1989
Quote:easy, in PHP4 their is no static and so the scope resolution operator (: won’t work either.
I'm not so sure about that. I do remember from my past readings on the singleton pattern in php4, that a variable can remain static inside a method or a function. Also, revisiting an old database class that I had created for a past application, I see that I did use the pattern and was able to call my connections throughout my models with DB::query($query).
In the present case, it is not exactly a singleton as most of us know it, but rather some variant of it and I feel that I overdid it a little bit. I'll simplify:
Code:
class CI_Base {
function CI_Base()
{
self::instance(& $this);
}
function & instance($i=null){
static $instance;
if($i){
$instance = & $i;
}
return $instance;
}
}
function &get_instance(){
return & CI_Base::instance();
}
I guess I'm just wondering as to why the pattern was not applied here. Like I said I'm just an occasional php4 coder, but I've been going through the code and some things are just like puzzles, you need answers or you'll dream of them at night.