php訪問sybase16

1、cd /path/to/php-5.6.16/ 進入PHP源碼目錄 php

2、cd ext/sybase_ctsql

3、修改php_sybase_ct.c把涉及到mssql_等函數的代碼註釋掉(不然mssql模塊不能同時加載),具體修改以下apache

/*函數

#if !defined(PHP_WIN32) && !defined(HAVE_MSSQL)sqlserver

PHP_FALIAS(mssql_connect, sybase_connect, arginfo_sybase_connect)測試

PHP_FALIAS(mssql_pconnect, sybase_pconnect, arginfo_sybase_pconnect)fetch

PHP_FALIAS(mssql_close, sybase_close, arginfo_sybase_close).net

PHP_FALIAS(mssql_select_db, sybase_select_db, arginfo_sybase_select_db)debug

PHP_FALIAS(mssql_query, sybase_query, arginfo_sybase_query)code

PHP_FALIAS(mssql_unbuffered_query, sybase_unbuffered_query, arginfo_sybase_unbuffered_query)

PHP_FALIAS(mssql_free_result, sybase_free_result, arginfo_sybase_free_result)

PHP_FALIAS(mssql_get_last_message, sybase_get_last_message, arginfo_sybase_get_last_message)

PHP_FALIAS(mssql_num_rows, sybase_num_rows, arginfo_sybase_num_rows)

PHP_FALIAS(mssql_num_fields, sybase_num_fields, arginfo_sybase_num_fields)

PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, arginfo_sybase_fetch_row)

PHP_FALIAS(mssql_fetch_array, sybase_fetch_array, arginfo_sybase_fetch_array)

PHP_FALIAS(mssql_fetch_assoc, sybase_fetch_assoc, arginfo_sybase_fetch_assoc)

PHP_FALIAS(mssql_fetch_object, sybase_fetch_object, arginfo_sybase_fetch_object)

PHP_FALIAS(mssql_data_seek, sybase_data_seek, arginfo_sybase_data_seek)

PHP_FALIAS(mssql_fetch_field, sybase_fetch_field, arginfo_sybase_fetch_field)

PHP_FALIAS(mssql_field_seek, sybase_field_seek, arginfo_sybase_field_seek)

PHP_FALIAS(mssql_result, sybase_result, arginfo_sybase_result)

PHP_FALIAS(mssql_affected_rows, sybase_affected_rows, arginfo_sybase_affected_rows)

PHP_FALIAS(mssql_min_client_severity,   sybase_min_client_severity, arginfo_sybase_min_client_severity)

PHP_FALIAS(mssql_min_server_severity, sybase_min_server_severity, arginfo_sybase_min_server_severity)

PHP_FALIAS(mssql_set_message_handler, sybase_set_message_handler, arginfo_sybase_set_message_handler)

PHP_FALIAS(mssql_deadlock_retry_count, sybase_deadlock_retry_count, arginfo_sybase_deadlock_retry_count)

#endif

*/

若是無需經過mssql.o模塊用php訪問mssql server則可忽略這一步(用dblib pdo訪問不受次影響)

Linux下php訪問遠程mssq可參考本人的以下博文

Linux下php訪問遠程ms sqlserver

4、/opt/php/bin/phpize生成編譯配置文件 

5、./configure --with-php-config=/opt/php/bin/php-config -with-sybase-ct=/opt/sybase/OCS-16_0

6、make&sudo make install

編譯完成在/opt/php/lib/php/extensions/no-debug-zts-20131226/目錄下生成sybase_ct.so

7、修改php.ini,將該模塊載入: 

extension=sybase_ct.so

8、重啓apache服務

sudo service apachectl stop

sudo service apachectl start

9、測試代碼

<?php
/* connect to database */
sybase_connect('MYMOTIFVOSTRO145480', 'sa', 'wxwpxh') or
die("Could not connect");
sybase_select_db("testdb");



$result=sybase_query("SELECT * FROM STUDENT");  
while($row=sybase_fetch_array($result))  
{  
   echo $row[0];
   echo '::';
   echo $row[1];
   echo "<br>";   
}  
?>

 

安裝sybase時sybase用戶主目錄爲/opt/sybase可正常運行,如爲/home/sybase時將/opt/sybase下的文件和目錄都軟鏈接到用戶主目錄下。$ ln -s /opt/sybase/* .

相關文章
相關標籤/搜索