I am trying to add extra properties to my Kohana (v3.3) model.
class Model_mymodel extends ORM {
protected $_myvar = NULL;
public function set_myvar() {
$this->_myvar = new Newclass();
}
public function get_myvar() {
return $this->_myvar;
}
}
And then I try and set it
$inst = ORM::factory('mymodel', 1)->find();
$inst->set_myvar();
var_dump($inst->get_myvar());
This returns NULL. I dont see why this would be a problem. Is there something that I am missing?
Thanks
extend the
__get
methodThis way the
Newclass
is instantiated automatically if it doesn't exist yet, solving two problems at once.