Eitan Feinberg Tue Oct 12 16:14:01 -0400 2010

Subject: get_fullname not working

I tried to set-up a getter

function get_fullname() {
return "$this->firstname $this->lastname";

but when I call

$person = User::first();
echo $person->fullname;

I get an error, UndefinedPropertyException, because ...ActiveRecord\Model->read_attribute('fullname')... which is a field that doesn't exist in the db. Am I doing something wrong or is this a bug? Thanks for the help in advance! - Eitan

Keith Thibodeaux Tue Oct 12 18:28:22 -0400 2010

To get the user's first name:

Last name:

However, since get_fullname is a function, you call

Jacques Fuentes Tue Oct 12 21:00:21 -0400 2010

You need to use the latest version of php-ar to use getters without declaring them in static vars.

Eitan Feinberg Wed Oct 13 12:55:41 -0400 2010

Thanks Jacques, I downloaded the nightly build and now it works perfectly! Keith's solution would have worked but i was going for the coding zen that was in the documentation!