How to specify username and password in the DSN?

寵の児 提交于 2020-02-02 05:24:41

问题


The official documentation page for PDO DSN does not list out username or password yet. What is the correct name for these key-value pairs?


回答1:


Looks like the documentation hasn't been updated yet, but this is the related change from PHP's source repository, stating how it should be used:

  • PDO: The username and password can now be specified as part of the PDO DSN for the mysql, mssql, sybase, dblib, firebird and oci drivers. Previously this was only supported by the pgsql driver. If a username/password is specified both in the constructor and the DSN, the constructor takes precedence.

    new PDO("mysql:host=xxx;port=xxx;dbname=xxx;user=xxx;password=xxx");
    

And here's the associated pull request.



来源:https://stackoverflow.com/questions/59448952/how-to-specify-username-and-password-in-the-dsn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!