inheriting from non similar types?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
           skype: d3ntaku
           http://www.pikkle.com
           +81 (0)90-7414-6107

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux