DSN -- The data source name
Description
To connect to a database through PEAR::DB, 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 with protocol
|
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.db
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
msql -> Mini SQL
mssql -> Microsoft SQL Server
oci8 -> Oracle 7/8/8i
odbc -> ODBC (Open Database Connectivity)
sybase -> SyBase
ifx -> Informix
fbsql -> FrontBase |
With an up-to-date version of DB, you can use a
second DSN format
phptype(syntax)://user:pass@protocol(proto_opts)/database
example:
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 |
Important! |
Please note, that some features may be not supported by all
database backends. Please refer to the PEAR DB extensions
status document located at:
„<pear base dir>/DB/STATUS“
to get a detailed list about what features are supported by which
backend.
|