Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14366 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66967 invoked by uid 1010); 12 Jan 2005 19:37:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 66928 invoked by uid 1007); 12 Jan 2005 19:37:46 -0000 Message-ID: <20050112193745.66927.qmail@pb1.pair.com> To: internals@lists.php.net References: <20050112155751.33379.qmail@pb1.pair.com> <20050112161637.86918.qmail@pb1.pair.com> <20050112190726.23678.qmail@pb1.pair.com> <41E5790D.2090402@cschneid.com> Date: Wed, 12 Jan 2005 20:39:48 +0100 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Posted-By: 217.86.168.9 Subject: Re: Get name of extending class with static method call (PHP5) From: roehr@zilleon.com ("Torsten Roehr") "Christian Schneider" wrote in message news:41E5790D.2090402@cschneid.com... > Torsten Roehr wrote: > > Something so straightforward and fundamental should be possible!?! > > Maybe is isn't as fundamental as you think? I never came across this > problem in years of PHP programming. But then again I use classes with > static calls for nothing but separate namespaces :-) > > I'm pretty sure there is another (possibly more elegant) solution. This > is not a flame but a suggestion to rethink the problem you are trying to > solve. > > - Chris Hi Chris, no problem - not feeling flamed here ;) Maybe I should elaborate a bit more what I'm needing this for. I would like to write a load method in a superclass that can be used by all subclasses. I'm just passing in the SQL statement as a parameter. The load method commits the query, loops through the result set and creates/returns a collection of objects. The method needs to know the name of the class to create objects of this class. Example: $persons = Person::load($sql); // returns collection of Person objects $cars = Car::load($sql); // returns collection of Car objects All classes can use the same load method and the database access (for selects) is only needed in this method and can therefore be changed easily. It's a bit simplified but I hope you get the idea. Also from the heated discussion on php-general you can see that there are quite a few people facing the described problem. Best regards, Torsten Roehr