(1-1/1)
See http://www.phpactiverecord.org/docs/ActiveRecord/Model#method__set :
You can define a method set_virtual_name($value) and get_virtual_name() - these will be called by $model->virtual_name.
(Note that for v1.0, you need to declare those setters&getters in the static variables $setters/$getters - nightly build will do it without them.)
(1-1/1)
June 27 2010
May 8, 2013
Subject: [SOLVED] Best approach to 'virtual attributes' ?
[UPDATE] Sorry all, I found the answer.. feel like a bit of a dope! - http://www.phpactiverecord.org/docs/ActiveRecord/Serialization#var$attributes
Hi.
Just wondering what's the best approach to achieving 'virtual attributes', similar to http://railscasts.com/episodes/16-virtual-attributes ?
I've been using __get() and __set(), but wondering if there's a nicer way ?
Thanks,
Ash.