PHP Doku:: Connecting to Microsoft SQL Server and Sybase databases - ref.pdo-dblib.connection.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAbstraktionsebenenPHP Data ObjectsPDO TreiberMicrosoft SQL Server and Sybase Functions (PDO_DBLIB)PDO_DBLIB DSN

Ein Service von Reinhard Neidl - Webprogrammierung.

Microsoft SQL Server and Sybase Functions (PDO_DBLIB)

<<Microsoft SQL Server and Sybase Functions (PDO_DBLIB)

Firebird/Interbase Functions (PDO_FIREBIRD)>>

PDO_DBLIB DSN

(PECL PDO_DBLIB >= 0.9.0)

PDO_DBLIB DSNConnecting to Microsoft SQL Server and Sybase databases

Beschreibung

The PDO_DBLIB Data Source Name (DSN) is composed of the following elements:

DSN prefix

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.

host

The hostname on which the database server resides. Defaults to 127.0.0.1.

dbname

The name of the database.

charset

The client character set.

appname

The application name (used in sysprocesses). Defaults to "PHP Generic DB-lib" or "PHP freetds".

secure

Currently unused.

Beispiele

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


2 BenutzerBeiträge:
- Beiträge aktualisieren...
ulisse at atc dot bologna dot it
11.03.2010 14:38
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);
// ...
?>
slach at 74mail dot ru
4.02.2009 11:11
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'



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)