RE: Storing inheritance info in a DB

From: Date: Thu, 11 May 2000 07:28:40 +0000
Subject: RE: Storing inheritance info in a DB
Groups: php.general 
Request: Send a blank email to php-general+get-17@lists.php.net to get a copy of this message
Hi All, I've tested Shandy's code; this seems to work as expected (I've stripped db-related functions for simplicity). <? class Fruit { var $weight; function recThaw( $id ) { $fruitType = "Banana"; // This value should come from a DB $str = "\$temp = new $fruitType;"; eval( $str ); $temp->thaw($id); $temp->weight = 3; // This value should come from a DB //$this = $temp; <-- Win95+Apache+PHP crashes here :-( return $temp; } function whatami() { echo "<BR>Fruit"; } } class Banana extends Fruit { var $length; function thaw( $parentID ) { $this->length = 5; // This value should come from a DB } function whatami() { echo "<BR>Banana"; } } $asdf = new Fruit; $asdf = $asdf->recThaw(1); $asdf -> whatami(); echo "<BR> asdf-weight: ". $asdf->weight; echo "<BR> asdf-length: ". $asdf->length; ?> Hope this help! Lou -- Luca Balzerani, lou@latoserver.it

« previous php.general (#17) next »