How do I create a dynamic method in PHP?
Posted
by sandelius
on Stack Overflow
See other posts from Stack Overflow
or by sandelius
Published on 2010-03-29T14:26:42Z
Indexed on
2010/03/29
14:33 UTC
Read the original article
Hit count: 133
I'm trying to extend my ActiveRecord class with some dynamic methods. I would like to be able to run this from my controller
$user = User::find_by_username(param);
$user = User::find_by_email(param);
I've read a little about overloading and think that's the key. I'v got a static $_attributes
in my AR class and I get the table name by pluralizing my model (User = users) in this case.
How do I do this? All models extends the ActiveRecord class.
© Stack Overflow or respective owner