In general, $ DSN is a string, its format is as follows: phpoType (dbsyntax): // username: Password @ protocol hostspec / data
* PhpType: The type name of the PHP backend database (such as MySQL, ODBC, etc.) * DBSYNTAX: The SQL grammar standards used by the database are generally not. * Protocol: The communication protocol used is used. (Such as TCP, UNIX, etc.) * HostSpec: Description of the host where the database is located. (Form is: Host Name [: Port Number]) * Database: The name of the database. * Username: The username of the landing. * Password: The password of the login.
For DSN, common form below: * phptype: // username: password @ protocol hostspec: 110 // usr / db_file.db * phptype: // username: password @ hostspec / database_name * phptype: // username: password @ Hostspec * phpoType: // username @ hostspec * phptype: // hostspec / database * phpoType: // Hostspec * phpoType (dbsyntax) * phpoType
The default value is used for omitted parts.
Of course, $ DSN can also be an array, the form of array is as follows: $ dsn = array ('phpo = =>' MySQL ',' dbsyntax '=>', 'protocol' => ',' HostSpec '=> 'localhost', 'Database' => 'Test', 'username' => 'root', 'password' => '')