This article summarizes various DNS setting methods in PDO connection database in PHP. Share to everyone for your reference, specific as follows:
The DNS writing method in PDO is as follows:
MSSQL: Host=localhost;dbname=testdb
Sybase: Host=localhost;dbname=testdb
dblib: Host=localhost;dbname=testdb
Firebird: User=john; Password=mypass;database=database. Gde;datasource=localhost; port=305
DRIVER={IBM DB2 ODBC DRIVER};D atabase=database; Hostname=hostname; Port=port; Protocol=tcpip; Uid=username; Pwd=password;
Informix: host=host.domain.com; service=9800;
database=common_db; Server=ids_server; PROTOCOL=ONSOCTCP;
Enablescrollablecursors=1
MySQL: host=localhost;port=3307;dbname=testdb
MySQL: unix_socket=/tmp/mysql.sock;dbname=testdb
OCI:d bname=//localhost:1521/mydb
ODBC: TestDB
ODBC:D RIVER={IBM DB2 ODBC DRIVER}; Hostname=localhost; Port=50000;database=sample; Protocol=tcpip; Uid=db2inst1; PWD=IBMDB2;
ODBC:D river={microsoft Access Driver (*.mdb)};D Bq=c:\\db.mdb; Uid=admin
pgsql: host=localhost port=5432 dbname=testdb user=bruce password=mypass
SQLite:/opt/databases/mydb.sq3
Sqlite::memory:
Sqlite2:/opt/databases/mydb.sq2
Sqlite2::memory
More about PHP Interested readers can view the site topics: "PHP based on PDO Operation Database Skills Summary", "PHP+MONGODB Database Operation Skills Encyclopedia", "PHP object-oriented Programming Program Introduction", "PHP string (String) Usage Summary", " Introduction to PHP+MYSQL Database operations and a summary of PHP common database operations Tips
I hope this article will help you with the PHP program design.