连接到PHP(Windows/Linux)中的SQL 2008服务器


Connect to an SQL 2008 server in PHP (Windows/Linux)

对于我们的项目,我们需要连接到PHP Codeigner中的SQL服务器。我们的服务器运行在带有Centos的Linux网络服务器上。

通常情况下,我们通常使用MYSQL进行连接。对于此项目,SQL 2008服务器已存在。

有可能在这样的Linux机器上连接到SQL 2008服务器吗?我需要什么?是否也可以在本地网络中首先在我的Xampp开发中测试连接?

我在通过ODBC驱动程序运行SQL Server连接方面取得了最大的成功。你试过了吗?

http://technet.microsoft.com/en-us/library/hh568454.aspx

Try->在您的应用程序/config/database.php中放入以下内容:

// This address is valid if you're on the same domain as the server:
// If not, you can put the ip address or url here as well.
$db['default']['hostname'] = 'DBComputerName'SQLEXPRESS';
// if you need a non default port uncomment and edit
//$db['default']['port'] = '5432';
$db['default']['username'] = 'databaseUsername';
$db['default']['password'] = 'databaseenter code herePassword';
$db['default']['database'] = 'DatabaseName';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;