Introduction - DSN
Description
To connect to a database through PEAR::MDB, 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
,odbc
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 withprotocol
The format of the supplied DSN is in its fullest form:
phptype(dbsyntax)://username:password@protocol+hostspec/database
Most variations are allowed:
phptype://username:password@protocol+hostspec:110//usr/db_file.mdb phptype://username:password@hostspec/database_name phptype://username:password@hostspec phptype://username@hostspec phptype://hostspec/database phptype://hostspec phptype(dbsyntax) phptype
The currently supported database backends are:
mysql -> MySQL pgsql -> PostgreSQL ibase -> InterBase mssql -> Microsoft SQL Server oci8 -> Oracle 7/8/8i fbsql -> FrontBase
With an up-to-date version of MDB, you can use a second DSN format
phptype(syntax)://user:pass@protocol(proto_opts)/database
Connect to database through a socket
mysql://user@unix(/path/to/socket)/pear
Connect to database on a non standard port
pgsql://user:pass@word@tcp(localhost:5555)/pear
Please note, that some features may be not supported by all database backends. Please refer to the PEAR MDB extensions status document located at:
<pear base dir>/MDB/STATUS
to get a detailed list about what features are supported by which backend.