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); }
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!