So I just started learning to use ORM, went with Jelly when I first started learning Ko3, and have run into a few questions… they may seem stupid so please bear with me.
First I noticed that declaring the Model is enough to start using it, without having to break down the fields. Is this some automagic I’m unaware of? If so… does it cause performance issues and should it be avoided?
I’ve also noticed two different ways of declaring rules… what’s the difference between these two methods?
public function rules() {
return array(
'categoryname' => array(
array('not_empty'),
),
);
}
protected $_rules = array(
'categoryname' => array(
'not_empty' => true,
),
);
SHOW COLUMNSon empty model. But you can simply cache it.rules()was added in Kohana 3.1 (3.0 uses$_rulesproperty). Now you can apply some logic before return rule list. And its better for model extending, for example: