inheriting from non similar types?
| From: | D_C | Date: | Sun, 13 Feb 2005 07:30:55 +0000 |
| Subject: | inheriting from non similar types? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-208595@lists.php.net to get a copy of this message | ||
Hiya -
I want to create a class that inherits from a database object.
eg I have my own "user" Class, with general methods that do calculations etc.
However, it also reflects a table of the database, eg "age, location".
I want some methods called on the object to be handled by my class, but other
so at constructor time, something like
$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->age
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?
thanks!
/dc
--
_______________________________________________
David "DC" Collier
mobile business creator |モバイル・ビジネス・クリエーター
dc@pikkle.com
skype: d3ntaku
http://www.pikkle.com
+81 (0)90-7414-6107