PDO_DBLIB DSN

(PECL PDO_DBLIB >= 0.9.0)

PDO_DBLIB DSNMicrosoft SQL Server および Sybase データベースに接続する

説明

PDO_DBLIB データソース名 (DSN) は以下の要素で構成されます。

DSN 接頭辞

PDO_DBLIB が Sybase ct-lib ライブラリに対してリンクされている場合は DSN 接頭辞は sybase: です。 Microsoft SQL Server ライブラリに対してリンクされている場合は mssql:、そして FreeTDS ライブラリに対してリンクされている場合は dblib: となります。

host

データベースサーバーが存在するホスト名を指定します。 デフォルトは 127.0.0.1 です。

dbname

データベース名を指定します。

charset

クライアントの文字セットを指定します。

appname

アプリケーション名を指定します (sysprocesses で使用します)。 デフォルトは "PHP Generic DB-lib" あるいは "PHP freetds" です。

secure

現在は未使用です。

例1 PDO_DBLIB DSN の例

以下の例は、Microsoft SQL Server および Sybase データベースに接続するための PDO_DBLIB DSN を表します。

mssql:host=localhost;dbname=testdb
sybase:host=localhost;dbname=testdb
dblib:host=localhost;dbname=testdb

add a note

User Contributed Notes 3 notes

up
10
michal at durys dot pl
12 years ago
If you're using FreeTDS driver and you want to use "charset" parameter then you may have to edit freetds.conf (e.g. /etc/freetds/freetds.conf) and force connection using at least version 7.0 of the protocol.

tds version = 7.0

Charset parameter accepts all encodings supported by iconv (execute iconv --list to show all encodings).
up
9
Anonymous
9 years ago
Instead of specifying tds version and client charset in freetds.conf, you may pass it as a parameter.
<?php $dsn = 'dblib:version=7.0;charset=UTF-8;host=domain.example.com;dbname=example;'; ?>
up
5
slach at 74mail dot ru
16 years ago
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'
To Top