[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-internals
Subject:    [PHP-DEV] Allow PDO::query() to return a subclass of PDOStatement
From:       81.97.205.128
Date:       2005-05-18 13:26:13
Message-ID: 20050518132615.55570.qmail () lists ! php ! net
[Download RAW message or body]

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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic