Re: inheriting from non similar types?
| From: | Burhan Khalid | Date: | Sun, 13 Feb 2005 08:07:03 +0000 |
| Subject: | Re: inheriting from non similar types? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208596@lists.php.net to get a copy of this message | ||
D_C wrote:
$this->parent = mysql_fetch_object($res); // returns a mysql obj with age, loc etc records then ... $age = $userObj->age; // this actually comes straight from the dbase obj $rating = $userObj->rating; // a public var calculated at construction $life = $userObj->getSpend(); // this is a method to do a calc. I could use a component (is the right OOP pattern word?) $age = $userObj->dbObj->ageI believe the correct term for this is an object.
but I wanted to hide where the items are coming from. Also i want to be able to just keep adding to the database without having to create gettter/settter functions for everything... I think python had some nice means of doing get/set functions transparently, does PHP5 have anything like this?PHP5 does have get and set functions ( http://www.php.net/manual/en/language.oop5.overloading.php ) however, your problem might be extrapolating all the properties of the object, because if you change your database structure, then you wil have new properties in $dbObj.