Link to home
Start Free TrialLog in
Avatar of ucsdmbdm
ucsdmbdm

asked on

PHP OOP dynamically add class variables

Hi,
I would like to create a class with variable number of class properties from a database.
For example:
User class{
var $firstname;
var $lastname;  
}
or it could be
User class{
var $firstname;
var $lastname;
var $age;
}
in the first case above firstname and lastname are returned by the database but in the second case 3 things are returned from the database so we dont know the properties beforehand.

Is it possible to loop through the database and create class properties from the database?




ASKER CERTIFIED SOLUTION
Avatar of lexlythius
lexlythius
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial