RE: Storing inheritance info in a DB
[email protected] (Luca Balzerani)
| Newsgroups | php.general |
|---|---|
| Message-ID | <[email protected]> |
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, [email protected]