âÁÚÙ ÄÁÎÎÙÈ (Previous) (Next) Introduction - Connect

Last updated: Sun, 16 May 2004

Introduction - DSN

Introduction - DSN -- The Data Source Name

ïÐÉÓÁÎÉÅ

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. When using ODBC as the phptype, set this to the DBMS type the ODBC driver is connecting to. Examples: access, db2, mssql, navision, solid, 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 format of the supplied DSN is in its fullest form:
phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value

Most variations are allowed:
phptype://username:password@protocol+hostspec:110//usr/db_file.db
phptype://username:password@hostspec/database
phptype://username:password@hostspec
phptype://username@hostspec
phptype://hostspec/database
phptype://hostspec
phptype:///database
phptype:///database?option=value&anotheroption=anothervalue
phptype(dbsyntax)
phptype

The currently supported database backends are:
dbase  -> dBase
fbsql  -> FrontBase
ibase  -> InterBase
ifx    -> Informix
msql   -> Mini SQL
mssql  -> Microsoft SQL Server
mysql  -> MySQL (for MySQL <= 4.0)
mysqli -> MySQL (for MySQL >= 4.1) (since DB 1.6.3)
oci8   -> Oracle 7/8/9
odbc   -> ODBC (Open Database Connectivity)
pgsql  -> PostgreSQL
sqlite -> SQLite
sybase -> Sybase

With an up-to-date version of DB, you can use a second DSN format
phptype(syntax)://user:pass@protocol(proto_opts)/database

If your username or password contain characters used to delineate DSN parts, you can escape them via URI hex encodings:
: = %3a   / = %2f   @ = %40
+ = %2b   ( = %28   ) = %29
? = %3f   = = %3d   & = %26

Внимание

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/doc/STATUS to get a detailed list about what features are supported by which backend.

âÁÚÙ ÄÁÎÎÙÈ (Previous) (Next) Introduction - Connect

Download Documentation Last updated: Sun, 16 May 2004
Hosting
HIVE: All information for read only. Please respect copyright!
Hosted by hive ÊÃÁ: Êèåâñêàÿ ãîðîäñêàÿ áèáëèîòåêà