codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Implement property overloading

Open inda5th opened this issue 13 years ago • 4 comments
trafficstars

This will allow outside classes to be able to read properties of the MY_Model class when necessary.

inda5th avatar Sep 19 '12 00:09 inda5th

Could you show an example of where this might be useful?

jamierumbelow avatar Sep 19 '12 07:09 jamierumbelow

@jamierumbelow I just thought it would be useful for when you have have other models that aren't based on MY_Model, and don't wish to make them children of MY_Model for whatever reason. So you could do $this->my_model_child->primary_key.

In my case, I have an application that I began before I discovered MY_Model, and don't wish to convert all the older models.

inda5th avatar Oct 17 '12 23:10 inda5th

Rather than using __get() - your implementation is wrong anyway, since you're just returning the property name as a string value - wouldn't it be better to just convert over the protected and private properties to public?

jamierumbelow avatar Oct 18 '12 14:10 jamierumbelow

Ooops, I didn't even realize I implemented it improperly.

inda5th avatar Oct 19 '12 15:10 inda5th