資源:freetds ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/
php4源代碼: http://www.php.net
步驟:
第一步:編譯并安裝freetds:
cd /tmp/
tar xzf freetds-*.tgz
cd freetds-*/
./configure --prefix=/usr/local/freetds
gmake
gmake install
第二步:編譯并安裝php4
./configure --with-mysql --with-sybase=/usr/local/freetds ....(后面的參數根據各自的需要不一而同)
#例子(我的編譯參數): ./configure --prefix=/usr/local/php --with-mysql --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-jpeg-dir=/usr --with-png --with-freetype --with-ttf --enable-gd-native-ttf --with-gd --enable-sockets --enable-dio --with-sybase=/usr/local/freetds --with-dom
make
make install
第三步:配置freetds
vim /usr/local/freetds/etc/freetds.conf
具體配置見該文件中的說明
例:
[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0
并且可以把不用的JDBC區間注釋掉
第四步:配置php.ini文件
修改相關的mssql區間配置,默認可以不用修改
第五步:測試
mssql_connect("192.168.0.1:1433","sa","");
mssql_select_db('testdb');
$sql = "SELECT * FROM test_table where condition = '條件';";
$result = mssql_query($sql);
$row = mssql_fetch_array($result);
print_r($row);
?>
不出意外的話,你將看到你期望的結果.
以上步驟在: Redhat 9.0, Apache 2.0.52, PHP 4.3.11 環境下通過.
原文轉自:http://www.anti-gravitydesign.com