Inheritance with Models

96 views
Skip to first unread message

George Whewell

unread,
May 23, 2012, 9:13:42 AM5/23/12
to redbeanphp
Hello, wondering what the standard practice is for implementing
inheritance with models in redbean is.

For example I have an abstract model 'account' where most of the
shared code resides, extended to several different types of account

abstract class Model_Account extends RedBean_SimpleModel {
/* Shared methods */
function hello(){ return 'hello!'; }
}

class Model_SiteA_Account extends Model_Account {
function about_me(){ return 'site A account'; }
}
class Model_SiteB_Account extends Model_Account {
function about_me(){ return 'site B account'; }
}

Using R::find('sitea_account') returns the correct model, implementing
the methods from the parent class, but I can't seem to find a way to
return a mixed set of all accounts. R::find('account') obviously
doesn't find anything, and I can't seem to find a way to query
multiple tables at once.

Does anyone have any suggestions?

Thanks
Reply all
Reply to author
Forward
0 new messages