Home > Backend Development > PHP Tutorial > php odbc link sql server database

php odbc link sql server database

不言
Release: 2023-03-24 20:48:02
Original
2832 people have browsed it

The content of this article is about php odbc link to sql server database. It has certain reference value. Now I share it with everyone. Friends in need can refer to it

$mssqldriver = '{SQL Server}';


/*$mssqldriver = '{SQL Server Native Client 11.0}';


$mssqldriver = '{ODBC Driver 11 for SQL Server}';*/

//三句任选一句就可以了



$hostname='';//服务器地址或IP,有端口要用逗号链接。


$dbname='';//数据库名


$username='';//用户名


$password='';//数据库密码


//使用ODBC方式连接
$dbDB= new PDO("odbc:Driver=$mssqldriver;Server=$hostname;Database=$dbname", $username, $password);

$sql = "SELECT * FROM Bns_Company";
$SQL = iconv("utf-8", "gbk", $SQL);
foreach ($dbDB->query($sql) as $row) {
    var_dump($row);
}
Copy after login

Related recommendations:

PHP method code for linking redis

#The simplest method for PHP to link ACCESS database



The above is the detailed content of php odbc link sql server database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template