Set WeberTrivia.com to be my default homepage.   Suggest a Question                                               

Suggest A Question : :  Frequently Asked Questions : :  Search : :  Relevant Manuals : : 
PHP Questions : :  Linux Questions : :  MySQL Questions : : 
home  [ Login ] 

Introduction - DSN

Introduction - 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. 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 servers running MySQL <= 4.0) mysqli -> MySQL (for servers running MySQL >= 4.1) 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

Warning

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.

Who's Online
Guest Users: 12
Google
Web
WeberTrivia
WeberDev
WeberForums
 Free Sample Chapters  Free Sample Chapters
  Deliver First Class Web Sites: 101 Essential Checklists
Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?

More Sample Chapters

PHP General