Dynamically determine class

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

 



Hi,

I'm using PHP5 and try to do something like this:

I have a base class called 'Entry' and a child class called 'ExtendedEntry'. I want to read all Entries to a certain topic from a database.

While constructing the EntryObject I would like to look if Entry is a simple Entry or an ExtendedEntry. I want the new object to be an ExtendedEntry - if possible - and otherwise to be an Entry.

It was not possible to return the object in the __construct() function and it was not possible to reassign $this with code like
	$this = new ExtendedEntry()
also in the __construct() function. And I tried to always generate an ExtendedEntry with a flag, that says it is really Extended and a typecast afterwards, but I wasn't able to typecast to another object by (Entry) $extEntry.

Any suggestions how to solve this problem without writing a generateEntry() function, that looks into the database and then calls the correct class type?

thanks in advance,
Norbert

--
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