php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #74957 Introduce interfaces PDOInterface and PDOStatementInterface
Submitted: 2017-07-20 13:34 UTC Modified: 2021-08-09 11:32 UTC
From: aljosha dot papsch at vinexus dot eu Assigned:
Status: Suspended Package: PDO related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aljosha dot papsch at vinexus dot eu
New email:
PHP Version: OS:

 

 [2017-07-20 13:34 UTC] 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.


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-20 14:07 UTC] 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-28 06:43 UTC] andrew dot nester dot dev at gmail dot com
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 :)
 [2017-10-24 08:32 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 [2021-08-09 11:32 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2021-08-09 11:32 UTC] cmb@php.net
> Will see how it goes :)

Apparently, it did not, and someone would need to pursue the RFC
process[1].  For the time being, I suspend this ticket.

[1] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC