Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: Microsoft SQL Server および Sybase 関数 (PDO_DBLIB) - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDO_DBLIB DSN" width="11" height="7"/> <mssql_select_db
Last updated: Thu, 31 May 2007

view this page in

XCIII. Microsoft SQL Server および Sybase 関数 (PDO_DBLIB)

導入

警告

この拡張モジュールは、 実験的 なものです。この拡張モジュールの動作・ 関数名・その他ドキュメントに書かれている事項は、予告なく、将来的な PHP のリリースにおいて変更される可能性があります。 このモジュールは自己責任で使用してください。

PDO_DBLIB は PHP Data Objects (PDO) インターフェイスを実装したドライバで、 PHP から Microsoft SQL Server および Sybase データベースに対して FreeTDS ライブラリを使用したアクセスが可能となります。

Windows では、Microsoft SQL Server や Sybase データベースにアクセスする際には PDO_ODBC ドライバを使用すべきです。 Windows 版のネイティブの DB-LIB は時代遅れになっており、 スレッドセーフではない上に Microsoft にもサポートされていません。

目次

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


PDO_DBLIB DSN" width="11" height="7"/> <mssql_select_db
Last updated: Thu, 31 May 2007
 
add a note add a note User Contributed Notes
Microsoft SQL Server および Sybase 関数 (PDO_DBLIB)
Steve H
01-Jun-2006 01:24
To connect to SQL Server 2005 Express on Windows, do it like this:

$pdo = new PDO ('mssql:host=localhost,1433;dbname=[redacted]', '[redacted]', '[redacted]');

localhost
localhost\SQLEXPRESS
localhost\1433
localhost:1433

will not work on Windows.

localhost,1433

does work.

YMMV on other OS's; try each.

Also make sure your TCP/IP Properties -> IP Addresses are correct under SQL Server Configuration Manager.
support at converters dot ru
25-Jan-2006 10:48
If You work with MSSQL Server 7.0/2000/... under Windows and use non latin Encoding then better To use PDO_MSSQL until PDO_ODBC bugs will be fixed (MSSQL ext far more stable and usabe for PHP versions <=5.1.2).
If your MSSQL connection use strings in OEM encoding (cp866 for russian charset)

1. Run Microsoft Server/Client Network Utility on work PC and UNCHECK "DBLibrary options"/"Automatic ANSI to OEM conversion"

2. Restart Web server if needed.
graham1 dot simpson at hsbcib dot com
08-Sep-2005 04:19
There is currently little sybase related PDO docs out there. The ones that I found often mention a spec for a dsn that is invalid. Here's how I am currently connecting to sybase ASE:

1. Compile up freetds http://www.freetds.org on top of open client;
2. Add the PDO and PD_DBLIB modules to php 5 as per the documentation; Note: I'm currently using the PDO-beta and PDO_DBLIB-beta;
3. Check mods installed ok using "pear list" and "php -m";

The documentation often says to use "sybase:" as your DSN, this doesn't work. Use "dblib:" instead. Here's an example:

<?php
  try
{
   
$hostname = "myhost";
   
$port = 10060;
   
$dbname = "tempdb";
   
$username = "dbuser";
   
$pw = "password";
   
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
  }
catch (PDOException $e) {
    echo
"Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
  }
 
$stmt = $dbh->prepare("select name from master..sysdatabases where name = db_name()");
 
$stmt->execute();
  while (
$row = $stmt->fetch()) {
   
print_r($row);
  }
  unset(
$dbh); unset($stmt);
?>

Hope this helps.

PDO_DBLIB DSN" width="11" height="7"/> <mssql_select_db
Last updated: Thu, 31 May 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites