Welcome Guest, Not a member yet? Register   Sign In
sqlsrv-driver in CI 2.1.0
#1

[eluser]Unknown[/eluser]
there are some problems while connecting CI 2.1.0 to Microsoft SQL-Server. The driver have some errors and did not return the correct value when trying in pconnect.

Perhaps you can try this patched driver:

#2

[eluser]Tybion[/eluser]
Thanks, Dumbledore.

That has saved me heaps of time. Has this new code been submitted to the development team for incorporation into CodeIgniter?

I downloaded CI 2.1.0 on Friday, and the connect still does not work without the supplied fix - copy the files to system/database/drivers/sqlsrv.

For example purposes, this is what worked for me in database.php ..

Code:
$active_group = 'dwh';

/* SQL Server - data warehouse - read */
$db['dwh']['hostname'] = 'maittestsql\testsql2008';
// $db['dwh']['hostname'] = 'maittestsql';
// $db['dwh']['port']     = 2646;        // no good - use server/instance instead
$db['dwh']['username'] = 'dwh';
$db['dwh']['password'] = 'password';
$db['dwh']['database'] = 'mydb';
$db['dwh']['dbdriver'] = 'sqlsrv';
$db['dwh']['dbprefix'] = '';
$db['dwh']['pconnect'] = TRUE;
$db['dwh']['db_debug'] = TRUE;
$db['dwh']['cache_on'] = FALSE;
$db['dwh']['cachedir'] = '';
$db['dwh']['char_set'] = 'utf8';
$db['dwh']['dbcollat'] = 'utf8_general_ci';
$db['dwh']['swap_pre'] = '';
$db['dwh']['autoinit'] = TRUE;
$db['dwh']['stricton'] = FALSE;
#3

[eluser]fanch[/eluser]
Thanks for your work!

Does it require to install some others applications to make it work?

My server is actually running a Debian distribution...

Thanks for your help.

Fanch
#4

[eluser]Tybion[/eluser]
I used the 'sqlsrv' driver supplied by Microsoft.
http://www.microsoft.com/download/en/con...x?id=17308 (version 3)
http://www.microsoft.com/download/en/det...n&id=20098 (version 2)

These are .dll files, though, so presumably this is only available for Windows.

Maybe go for the 'mssql' drivers on Debian ?
#5

[eluser]fanch[/eluser]
Thanks Tybion,

I've had to install sybase and freedts (i'm running PHP Version 5.3.6-13ubuntu3.3):
Code:
sudo apt-get install libsybdb5 freetds-common php5-sybase
sudo /etc/init.d/apache2 restart

Once installed you can check in phpinfo() answers that the installation was effective.

Thanks to all for your brillant work, CodeIgniter rules!
#6

[eluser]jonldavis[/eluser]
I'm having trouble getting this to work.

My setup is:
Codeigniter 2.1.0
IIS 7.5 w/ PHP FastCGI
SQL Server 2008 (not on web server)

I'm in a situation where I have to use Windows Authentication. I've verified that PHP/CI has access to the Windows user identity (printing out $_SERVER['REMOTE_USER'] gives correct result). I can connect to the database using the sqlsrv driver directly using this code in my config/database.php:
Code:
$serverName = $db[ENVIRONMENT]['hostname']; //serverName\instanceName

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( 'Database' => $db[ENVIRONMENT]['database']);
$conn = sqlsrv_connect( $serverName, $connectionInfo );

if ( $conn ) {
  echo "Connection established.<br />";
}
else {
  echo "Connection could not be established.<br />";
  die ( print_r( sqlsrv_errors(), true));
}
results in success.

But when I use the sqlsrv driver in CI with the exact same config I get "Unable to connect to your database server using the provided settings."

I made the fix mentioned in another post (http://ellislab.com/forums/viewthread/197527/) to sqlsrv_driver.php - the zip file file above doesn't seem to be there anymore, so I don't know if there's another bug in the provided driver.

Any ideas?
#7

[eluser]Unknown[/eluser]
I'm not able to access the zip file above too.
Anyone can share the file again.
Thanks.
#8

[eluser]Narf[/eluser]
There's a fix for that in the current develop branch:

https://github.com/EllisLab/CodeIgniter/...driver.php
#9

[eluser]mobs6[/eluser]
Well, i just want to shared if u dont want use the sqldrv from MSSQL, u could see this forum:
http://ellislab.com/forums/viewthread/213879/
#10

[eluser]mandaman2k[/eluser]
[quote author="Tybion" date="1327903410"]Thanks, Dumbledore.

That has saved me heaps of time. Has this new code been submitted to the development team for incorporation into CodeIgniter?

I downloaded CI 2.1.0 on Friday, and the connect still does not work without the supplied fix - copy the files to system/database/drivers/sqlsrv.

For example purposes, this is what worked for me in database.php ..

Code:
$active_group = 'dwh';

/* SQL Server - data warehouse - read */
$db['dwh']['hostname'] = 'maittestsql\testsql2008';
// $db['dwh']['hostname'] = 'maittestsql';
// $db['dwh']['port']     = 2646;        // no good - use server/instance instead
$db['dwh']['username'] = 'dwh';
$db['dwh']['password'] = 'password';
$db['dwh']['database'] = 'mydb';
$db['dwh']['dbdriver'] = 'sqlsrv';
$db['dwh']['dbprefix'] = '';
$db['dwh']['pconnect'] = TRUE;
$db['dwh']['db_debug'] = TRUE;
$db['dwh']['cache_on'] = FALSE;
$db['dwh']['cachedir'] = '';
$db['dwh']['char_set'] = 'utf8';
$db['dwh']['dbcollat'] = 'utf8_general_ci';
$db['dwh']['swap_pre'] = '';
$db['dwh']['autoinit'] = TRUE;
$db['dwh']['stricton'] = FALSE;
[/quote]

I got it working the following way on windows with wamp server:

1.Download http://www.microsoft.com/download/en/det...n&id=20098 (version 2) and copy the extracted files to the php/ext folder.
1.a. activate php_sqlsrv_53_ts_vc6 and vc9 extensions.
2. Edit file: https://github.com/EllisLab/CodeIgniter/...driver.php
3. In the config quoted above in hostname use double slash between server and instance
$db['dwh']['hostname'] = 'maittestsql\testsql2008'; => $db['dwh']['hostname'] = 'maittestsql\\testsql2008';

Hope this helps




Theme © iAndrew 2016 - Forum software by © MyBB