Anders Christiansen Sun Jul 01 20:04:50 -0400 2012

Subject: Check for existance of virtual properties doesn't work out of the box ...a solution (feedback wanted)

In phpactiverecord you can define 'virtual attributes' - attributes not corresponding to actual columns in the table - like so:

public function get_whatever{
return some_value;

Then you can use 'whatever' like any real attribute. For comparison:
$my_model->whatever // returns some_value, a virtual attribute
$my_model->id // returns id, a 'real' attribute (the id-column of model)

(see the example in

if you need to determine if a model has a given attribute it'll only work for 'real' attributes:

isset ($my_model->id) // returns true if the table has id column
isset ($my_model->whatever) // all ways returns false, 'whatever' being a virtual attribute

In case anyone has the same problem - this simple solution worked for me:

Change __isset method in Model.php (around line 342)


return array_key_exists($attribute_name,$this->attributes) || array_key_exists($attribute_name,static::$alias_attribute);


return array_key_exists($attribute_name,$this->attributes) || array_key_exists($attribute_name,static::$alias_attribute) || method_exists($this, "get_$attribute_name");

I can't vouch for this solution since I'm not a pro coder. Anyone with more insight into phpactiverecord might want to comment whether this is a viable solution or not. In given case it would be nice to have this feature incorporated into the nightly builds.