Hey guys!
I have a class which has a function to retrieve children elements from a database. The following code will be rather pseudo cause I want to keep it as easy as possible.
abstract class SomeHostObject extends SomeObject {
function getChild($identifier) {
global $database;
$id = $database->select('Some MySQL Query');
// that is the problem
return ?new? ???($id);
}
}
As you see, the class SomeHostObject
is abstract and has to be extended.
The thing is that the getChild()
should not return a SomeHostObject
instance (not only because it can't even be instantiated) but a new instance of the class that extends SomeHostObject
.
For example, if there was a class PageObject
which extends SomeHostObject
, the function getChild()
should return a new PageObject
instance with the new id.
I don't know whether to call that question 'advanced' or not but to me it's a major problem so c'mon and answer me. Right now! :D
Thanks a ton in advance!