To connect to a database through PEAR::MDB2, you have to create a
valid DSN - data source name. This DSN
consists in the following parts:
phptype:
Database backend used in PHP (i.e. mysql
, pgsql etc.)
dbsyntax:
Database used with regards to SQL syntax etc.
protocol:
Communication protocol to use ( i.e. tcp,
unix etc.)
hostspec:
Host specification (hostname[:port])
database:
Database to use on the DBMS server
username:
User name for login
password:
Password for login
proto_opts:
Maybe used with protocol
option:
Additional connection options in URI query string format.
options get separated by &.
The Following table shows a non complete list of options:
Some backends support setting the client charset. (Invokes
setCharset(string $charset, [resource $connection = null])
string
new_link [boolean]
Some RDBMS do not create new connections when connecting to the same host
multiple times. If this option is set to TRUE it will attempt to force
a new connection.
boolean
The DSN can either be provided as an associative array or
as a string.
The array format is preferred, since it doesn't require a further parsing step
(see the Connecting
chapter for an example).
The string format of the supplied DSN is in its fullest form: