Req #74957 [Com]: Introduce interfaces PDOInterface and PDOStatementInterface
| From: | andrew dot nester dot dev at gmail dot com | Date: | Fri, 28 Jul 2017 06:43:46 +0000 |
| Subject: | Req #74957 [Com]: Introduce interfaces PDOInterface and PDOStatementInterface | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210383@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74957&edit=1
ID: 74957
Comment by: andrew dot nester dot dev at gmail dot com
Reported by: aljosha dot papsch at vinexus dot eu
Summary: Introduce interfaces PDOInterface and
PDOStatementInterface
Status: Open
Type: Feature/Change Request
Package: PDO Core
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thanks for the reported request!
I've just created my PR and started internal discussion.
Here is the links:
https://github.com/php/php-src/pull/2657
http://news.php.net/php.internals/100067
Will see how it goes :)
Previous Comments:
------------------------------------------------------------------------
[2017-07-20 14:07:53] adambaratz@php.net
One way to approach this is by subclassing PDO and PDOStatement. You can use the PDO::
ATTR_STATEMENT_CLASS driver option to tell a PDO object which PDOStatement subclass to return from
PDO::prepare().
If you have a different use case in mind, an API change like this would require an RFC. There's
a description of the process here:
https://wiki.php.net/rfc/howto
------------------------------------------------------------------------
[2017-07-20 13:34:31] aljosha dot papsch at vinexus dot eu
Description:
------------
Classes PDO and PDOStatement do not implement any interface, making it harder to add custom
behaviour. For example, PDO does not handle reconnecting to database, which is an issue especially
in long running processes. The best shot at implementing this feature is creating custom behaviour
classes with the same methods as PDO/PDOStatement (most of it should just be adapter stuff).
Unfortunately the custom behaviour class cannot be used in functions which have PDO/PDOStatement
typehint, making them useless.
If PDO and PDOStatement implemented interfaces, it would be possible for the custom behaviour
classes to implement those interfaces as well, making them interchangeable. No changes needed in
callers of PDO/PDOStatement.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74957&edit=1