(PECL PDO_DBLIB >= 0.9.0)
PDO_DBLIB DSN — Connecting to Microsoft SQL Server and Sybase databases
The PDO_DBLIB Data Source Name (DSN) is composed of the following elements:
The DSN prefix is sybase:
if PDO_DBLIB was
linked against the Sybase ct-lib libraries,
mssql:
if PDO_DBLIB was linked against the
Microsoft SQL Server libraries, or dblib:
if
PDO_DBLIB was linked against the FreeTDS libraries.
The hostname on which the database server resides. Defaults to 127.0.0.1.
The name of the database.
The client character set.
The application name (used in sysprocesses). Defaults to "PHP Generic DB-lib" or "PHP freetds".
Currently unused.
Beispiel #1 PDO_DBLIB DSN examples
The following examples show a PDO_DBLIB DSN for connecting to Microsoft SQL Server and Sybase databases:
mssql:host=localhost;dbname=testdb sybase:host=localhost;dbname=testdb dblib:host=localhost;dbname=testdb
on Linux ppc64 / PHP 5.1.2 / freetds-0.64 works well this way:
<?php
// ...
$dbh = new PDO("dblib:host=$hostdb;dbname=$dbname", $usr, $psw);
// ...
?>
when you connect to non standart 1433 port
for win32 use DSN like 'mssql:host=hostname,port;dbname=database'
for FreeTDS and DB-Lib use DSN like 'mssql:host=hostname:port;dbname=database'