Okay, so nobody wants an update of PDO, or, at least, nobody wants to
design or implement PDO 2.0.
Meanwhile, we have almost universal problems with PDO that we might be able
to address by introducing a PDO provider of sorts.
The problems I have in mind are:
1. PDO instances connect immediately - putting a provider in front of it
enables constructor injection without eagerly opening the actual connection.
2. PDO instances do not provide access to their constructor values -
hostname, dbname etc. are lost at creation.
There are dozens of PDO extensions in the wild - they're almost universally
unusable, since most frameworks invent their own variation of this.
Standardizing on a provider, as opposed to some sort of PDO extension,
enables existing PDO extensions to coexist peacefully with this.
What I'm suggesting is a fairly unopinionated model facet, essentially
describing the constructor arguments you can give to the PDO constructor.
Something along the lines of this:
interface PDOProvider
{
public function getPDO(): PDO;
public function getProtocol(): string; // e.g. "mysql", "pgsql", etc.
public function getSetting(): array; // e.g. ["host"=>"localhost",
"dbname"=>"testdb"]
public function getUsername(): string;
public function getAttributes(): array; // e.g.
[PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"]
}
Note that getPassword() is omitted for security reasons. (it isn't
technically a liability in itself - you have the password in clear text if
you were able to pass it to the PDO constructor, but it doesn't seem
useful, and I suspect a lot of people will "perceive" this as a potential
security liability.)
This is just a quick draft.
Any thoughts?
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/a7a8240b-fb8b-4f1a-bfc1-ae2943964830%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.