I want to add dummy column in kohana ORM . I have a field of type longtext . I want to have a new field which contains it's strlen.
1条回答 默认 最新
- duanjingwei7239 2011-04-14 06:43关注
Use
$_ignored_columns
property:protected $_ignored_columns = array('text_length'); public function __get($column) { if ($column == 'text_length' && (! isset($this->_object['text_length']) || isset($this->_changed['text']))) { // recalc dummy field if not set, or on long text value changing return $this->_object['text_length'] = strlen($this->_object['text']); } return parent::__get($column); }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报