Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16275 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72599 invoked by uid 1010); 18 May 2005 13:37:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 55571 invoked by uid 1007); 18 May 2005 13:26:15 -0000 Message-ID: <20050518132615.55570.qmail@lists.php.net> To: internals@lists.php.net Date: Wed, 18 May 2005 14:26:13 +0100 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 81.97.205.128 Subject: Allow PDO::query() to return a subclass of PDOStatement From: nick.telford@ntlworld.com (Nicholas Telford) I've been going over PDO lately and I noticed that PDO::query() always returns a PDOStatement object. Now for the most part, this is fine, but it got me thinking. It's been said many times that PDO is not an abstraction layer, it's more of a unified interface, however, having PDO::query() always return a PDOStatement object means that any abstraction that uses PDO will either a) have to use PDOStatement as it's result set object (which while fine for the most part, kind of defeats the idea that PDO is not an abstraction layer) or b) create it's own result set object and populate it from the returned PDOStatement result set. Option "b" is somewhat of a waste since it involves the instantiation of two objects for the same purpose. What I'm proposing is to allow PDO::query() to return a subclass of PDOStatement. This would allow abstractions to tailor the result set to their own needs while not (in theory) being too complicated to implement. My initial idea involves passing an object that is a subclass of PDOStatement into PDO:query as a second parameter, then all that would be needed to get it to return a custom result set would be something like this: $results = $conn->query($sql,new ResultSet()); If I knew C, I'd write a patch for this, but since I don't, I thought I'd at least suggest this. ---------------- Nicholas Telford