Is there any short way to load data to the properties of a class, for each column name matching the properties of the class?
- by Ugur Gümüshan
I want to load data to an instance of an object using its constructor and I write
$this->property=$row["colname"]
each time for each property.
the mysql_fetch_object function fetches the data as an object but I am not sure if the instance of an object can be assigned to some object from inside. othwerwise I would use
__construct($object) { $this=$object; } //doesn't give any syntax error
Maybe I should look into iteration of properties and use
foreach($object as $key => $value) $value=$object[$key];
or can I assign like
$this=$object;
within the constructor?