JelleP
JelleP

Reputation: 1004

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

For our project we need to connect to an SQL server in PHP Codeigniter. Our server runs on an Linux webserver with Centos.

Normally we are common to use MYSQL to connect. For this project an SQL 2008 server already exist.

Is it possible to connect to an SQL 2008 server on such a Linux machine? And what do i need for that? Is it also possible to test the connecttion first in my Xampp dev in the local network?

Upvotes: 2

Views: 87

Answers (2)

Touhid
Touhid

Reputation: 659

Try-> in your application/config/database.php put the following:

// 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;

Upvotes: 0

JBC
JBC

Reputation: 112

I've had the greatest success with SQL Server connections running through ODBC drivers above anything else. Have you tried that yet?

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

Upvotes: 2

Related Questions