Hello,

I don't really understand why the provider should give access to the
Username of the PDO instance to be created, would this be for debugging
purposes?

I maybe would also prefer to have specific methods for retrieving the
hostname, port, database name, charset, etc.
But this will probably render the interface quite complicated so I'm also
fine as it is currently.

Best regards

George P. Banyard


On Mon, 28 Jan 2019 at 13:30, Rasmus Schultz <[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/php-fig/a7a8240b-fb8b-4f1a-bfc1-ae2943964830%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFPFaMLNmH5PbMDeFvD%2BV%3DPCE308YB%2BK1ZChugu%2BeokeW%2BtP4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to