Are you using the nightly build?
I got the one from January 17th, latest one.
Is status_pretty a field on your table? Getters work by declaring a function function get_name() where `name` is a field on your table.
It isn't a real field, it is just a virtual field.
What I want to do is when I do $company->status_pretty or what not, it takes the value of the column "status", which is a number, and finds the corresponding name for that number. So it's not an exact alias.
I see no reason why this wouldn't work. You may want to double check that you are definitely using the latest build of our framework and not the stable download. Please also provide me the full code example so I can solve your issue. Thanks.
I've encountered the same problem. The reason is really simple - bug in documentation:
http://www.phpactiverecord.org/docs/ActiveRecord/Model#method__get
There should be:
class User extends ActiveRecord\Model {
static $getters = array('name'); <----- missing line !!!!!!!
In setters you should also add:
http://www.phpactiverecord.org/projects/main/wiki/Utilities#attribute-setters
static $setters = array('name');
I found it in Model.php ;]
@Krzysiek where in Model.php?
This ons is the one: https://github.com/kla/php-activerecord/blob/master/lib/Model.php
Ok - i have old version od AR :(
I can see now it was changed:
elseif (method_exists($this,"set_$name")) {
$name = "set_$name";
return $this->$name($value);
}
Documentation is correct with actual version and I need update ;]
(1-10/10)
Subject: Simple getter
Hello I am trying to add a "getter" using this code:
function get_status_pretty() {
return 'test';
}
I would like to be able to do echo $company->status_pretty;
I added it to the company model of course.
Yet echo $company->status_pretty; says undefined property.