Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14367 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54561 invoked by uid 1010); 12 Jan 2005 20:05:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54510 invoked from network); 12 Jan 2005 20:05:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2005 20:05:00 -0000 X-Host-Fingerprint: 195.141.85.118 uf2.search.ch Linux 2.4/2.6 Received: from ([195.141.85.118:54829] helo=xaxa.search.ch) by pb1.pair.com (ecelerity HEAD (r4059)) with SMTP id 1B/C4-40505-CE285E14 for ; Wed, 12 Jan 2005 15:05:00 -0500 Received: from localhost (localhost [127.0.0.1]) by xaxa.search.ch (Postfix) with ESMTP id E6FF76D877; Wed, 12 Jan 2005 21:04:55 +0100 (CET) Received: by xaxa.search.ch (Postfix, from userid 65534) id B2E1C6D8BA; Wed, 12 Jan 2005 21:04:54 +0100 (CET) Received: from [192.168.1.72] (ultrafilter2-i [192.168.85.3]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by xaxa.search.ch (Postfix) with ESMTP id 416CA6D877; Wed, 12 Jan 2005 21:04:54 +0100 (CET) Message-ID: <41E582E5.3040200@cschneid.com> Date: Wed, 12 Jan 2005 21:04:53 +0100 User-Agent: Mozilla Thunderbird 1.0 (X11/20041207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Torsten Roehr Cc: 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> <20050112193745.66927.qmail@pb1.pair.com> In-Reply-To: <20050112193745.66927.qmail@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on xaxa.search.ch X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham version=2.64 X-Virus-Scanned: by AMaViS 0.3.12pre8 Subject: Re: Get name of extending class with static method call (PHP5) From: cschneid@cschneid.com (Christian Schneider) Hey Torsten, Torsten Roehr wrote: > $persons = Person::load($sql); // returns collection of Person objects > $cars = Car::load($sql); // returns collection of Car objects Simple solutions: 1) $persons = DB::load('Person', $sql); foreach ($persons as $person)... 2) $person = new Person($sql); while ($person->iterate())... 3) Adding get_class() to all DB classes (like Person) as suggested by Daniel Convissor. Solution 1) is IMHO close enough to your solution. Personally I prefer (and we are using) solution 2) here as it also is more space efficient for large number of results returned from the DB (only one Person object is needed). On top of that we create classes automatically at runtime from DB tables which removed the need to write stub classes (and makes solution 3) feasible again). I suggest that we take this discussion off-line now as it is not really an internals discussion anymore. - Chris