1、安装SQL Server驱动freetds

yum search freetds

yum install freetds php-mssql

或者下载编译安装

 
2、修改/etc/freetds.conf
 

[server2008]

        host = 192.168.70.119

        port = 1433

        tds version = 7.0

    client charset = utf8

 
 最好重启一下apache
3、测试连接
 
./tsql -S 192.168.0.109 -U 用户名 -P 密码 -D 数据库
如果可以有看到1>说明连接成功
输入sql语句
1>select * from table;
2>go
 
4、代码测试连接
 
<?php
$server = 'server2008 ';
$link = mssql_connect($server, 'sa', '123456');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
?>

5、测试PDO连接Sql server

这里用到了dblib

<?php
$db = new PDO("dblib:host=192.168.70.119;dbname=master","sa","123456");
$sql = "select top 3 * from spt_values";
$res = $db->query($sql);
while ($row = $res->fetch()){
print_r($row);
}
$res = null;
$db = null;
?>

结果:

Array ( [name] => jiqing [0] => jiqing [number] => 1 [1] => 1 [type] => A [2] => A [low] => [3] => [high] => [4] => [status] => 0 [5] => 0 ) Array ( [name] => pub [0] => pub [number] => 2 [1] => 2 [type] => A [2] => A [low] => [3] => [high] => [4] => [status] => 0 [5] => 0 ) Array ( [name] => sub [0] => sub [number] => 4 [1] => 4 [type] => A [2] => A [low] => [3] => [high] => [4] => [status] => 0 [5] => 0 )

linux centos6.4 php连接sql server2008的更多相关文章

  1. cenos6.5 64位下PHP远程连接sql server2008成功案例

    准备工作: 1.sql server2008服务器(开放远程端口,默认为1433,我用的是192.168.1.129) 2.安装好php的centos服务器 步骤: 1.php安装mssql扩展.ce ...

  2. php5.2 连接 SQL Server2008

    如果你见到下面这一段输出的话,那么你有福了!!!! Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => ...

  3. Java连接Sql Server2008

    参考:http://weistar.iteye.com/blog/1744871 准备工作: 1.下载JDBC驱动包:http://www.microsoft.com/zh-cn/download/d ...

  4. java 连接sql server2008配置

    Java 应用程序连接SQL Server2008 (Eclipse+JDK7.0+jdbc4.0.jar+Sql Server2008) 假设应用端的连接语句为: String url = &quo ...

  5. Linux平台使用Freetds连接SQL Server服务器,兼容PHP和Laravel

    本文在CentOS 7 64bit和Laravel 4.2环境测试通过.   1.下载源码并解压缩 wget ftp://ftp.freetds.org/pub/freetds/stable/free ...

  6. Unity3D(C#)连接SQL Server2008

    首先部署安装sql server2008,添加Sql Manager. Unity3D连接需要在Unity2017\Editor\Data\Mono\lib\mono\unity文件下找到4个头文件l ...

  7. Qt通过ODBC连接SQL Server2008实践总结

    Qt连接数据库的方式很多,这里说明一种最常用也是最实用的方式,因为这种方式在Windows上开发程序使用起来非常方便,并且也是远程连接数据库所需要用到的方式. 前提工作: 在Win7下安装了SQL S ...

  8. WAS6.1连接SQL Server2008数据库连接池配置

    原文链接:http://www.cnblogs.com/lyr2012/archive/2012/06/13/2547804.html 说明:该步骤只适用与websphere 6.1.0.15之前的版 ...

  9. jdk1.7 JDBC连接SQL Server2008

    路由器网:http://www.ming4.com/news/2355.html Jackie的博客:http://blog.163.com/jackie_howe/blog/static/19949 ...

随机推荐

  1. TableView 校检表

    这俩天学习了tableView 校检表 主要就是通过一个方法来跟踪当前选中的行.下面将声明一个NSIndexPath 的属性来跟踪最后选中的行.这篇文章希望能给那些初学者带来学习的乐趣.不说了直接上代 ...

  2. 有趣的JavaScript

    让你的js代码从一行开始,另一行结束: var s /*:String*/ = "Test \ multi \ line."; 看到没,只需要在你换行的字符串后面加上反斜线(bac ...

  3. poj 2049 Let it Bead(polya模板)

      Description Cannery Row percent of the target audience insists that the bracelets be unique. (Just ...

  4. 查看哪些进程占用了SWAP分区?

    在日常管理中,我们经常会遇到swap分区使用比较多,那么导致是那些进程使用的呢,其实我们可以通过/proc/pid/下的smaps来获得.使用下面的命令可以列出所有进程占用的swap分区的大小,分别我 ...

  5. mysql主从同步报错

    主从不同步,经查看发现如下报错 Last_Errno: 1666 ​Last_Error: Error executing row event: 'Cannot execute statement: ...

  6. 网页搜索功能 多表搜索sql

    SELECT ID, Title, FromTableFROM (SELECT ID, ArticleName AS Title, 'Article' AS FromTable        FROM ...

  7. css导航条

    #nav ul { display: none; position: absolute; padding-top: 0px;} #nav li:hover ul { display: block;}

  8. angular 指令梳理 —— checkBox

    checkBox 持久化数据为 逗号分割 /** * 功能说明: * htCheckbox 指令用于收集checkbox数据. * 在页面中使用 * 属性指令:ht-checkbox * 对应的值为s ...

  9. NSArray使用小结

    http://blog.csdn.net/ms2146/article/details/8654263

  10. iOS_SN_BlueTooth( 一)蓝牙相关基础知识

    原文  http://www.cocoachina.com/ios/20150915/13454.html 作者:刘彦玮 蓝牙常见名称和缩写 MFI ======= make for ipad ,ip ...