|
Posted by D_c on 02/13/05 09:30
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
Navigation:
[Reply to this message]
|