Welcome Guest, Not a member yet? Register   Sign In
mssql 2008 with PHP 5.3.2 and CI 1.7.2
#11

[eluser]Unknown[/eluser]
I found myself in a similar situations as OP...had to install a PHP product on Windows 2008 R2, IIS 7, MS SQL 2008 and PHP 5.3.2. On my dev machine all was working fine (Windows Vista, MS SQL 2008 Express, PHP 5.2.4).

The issue:
With regards to PHP 5.3.2...hmm, it seems PHP 5.3.2 does not ship with any MSSQL drivers...you have to download a driver from Microsoft (http://www.microsoft.com/sqlserver/2005/...river.aspx). Anyway, this has its own issues as the driver does not work with Codeigniter because it does not have the standard MSSQL API we are used to in PHP...according to the docs included in the download for the new dlls you have to use sqlsrv_connect instead of mssql_connect for example). SOOOO...it seems we need a new/updated SQLSrv Codeigniter driver class or modify the existing MSSQL driver class.

The fix:
I suggest you do not use PHP 5.3.2 to connect to MSSQL for now. I removed PHP 5.3.2 from the machine and installed the non thread safe PHP 5.2.13. That still comes with the standard MSSQL drivers. Codeigniter's MSSQL class can work with the MSSQL dll that gets shipped with PHP 5.2.13. On my machine I also had to update the ntwdblib.dll (but not on the client machine). On my machine the ntwdblib.dll was "outdated" according to some forums...I needed the 2000.80.194.0 version...which I downloaded. I had to replace each "old" ntwdblib.dll with the new one (had to stop the web server on my dev machine first) and then suddenly I could connect to MSSQL 2008 with PHP 5.2.4 using CodeIgniter 1.7.2...I did not have to make any changes to the Codeigniter database classes (had to modify some queries to work with MSSQL though...espcially in terms of queries that used LIMIT of course). My settings that worked are:

Code:
$db['default']['hostname'] = 'machinename\instance'; //in my case 'Juggernaut\SQL2008' but could be an IP address too
$db['default']['username'] = "user";
$db['default']['password'] = "passw";
$db['default']['database'] = "mydatabase";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

So, first try that out (PHP 5.2.13 and if needed update ntwdblib.dll) and make sure your database config file is set to use the mssql driver and not mysql (obvious I know, but just saying).

Let me know you you do not come right. There are more details with other PHP/IIS related things I struggled with (file permissions mostly - to write logs etc.) that I eventually got working...let me know if you need more info. They were not Codeigniter related though...just putting it out here.

In the mean time I will see about that new driver for PHP 5.3.2...its new to me and Im probably missing something obvious...but will probably end up modifying the existing Codeigniter MSSQL classes (which works with the php_mssql dll) to make a new SQLSRV driver (to work with the new php_sqlsrv dlls you download from Microsoft) to work in Codeigniter.
#12

[eluser]CI_adis[/eluser]
Hi Christiaan,

I face the same problem.. did you find something yet?

Loved to hear from you!

Regards,

ps in the mean time I will try your fix :-)
#13

[eluser]WanWizard[/eluser]
You can try Microsoft's drivers: http://msdn.microsoft.com/en-US/library/...L.90).aspx

Attached my first attempt at implementing a sqlsrv database driver. Not tested, I don't have windows here, but it will give you a starting point.
#14

[eluser]CI_adis[/eluser]
Hi WanWizard,

thanks for you reply again.
I have tried to implement your wunderfull try, but unfortunately i did not succeed! Altough i did get the following message:

Code:
A Database Error Occurred

Unable to connect to your database server using the provided settings.

So, it is doing more the 1hour ago.
I had to rename the class from

Code:
class CI_DB_mssql_driver extends CI_DB {
to
Code:
class CI_DB_sqlsrv_driver extends CI_DB {

tried to find out what is going wrong, but I'm just a beginner for PHP...

I will try in a few months. For now I will try to implement an ODBC!
Thanks again!
#15

[eluser]imorris[/eluser]
We too are getting the "Unable to connect to your database server..." error. Any resolution on this? We want to use the the new http://www.microsoft.com/downloads/en/de...ae6cf2ca05 driver but we just can't get it working.
#16

[eluser]CI_adis[/eluser]
Hi Imorris,

No did not manage to fix it, i think because i'm a beginner, just started with PHP.. but ODBC worked for me. So in a few month I will try it again, then I will hopefully be able to dig in PHP more than now..

If you oudn any resolution please post it...
#17

[eluser]CI_adis[/eluser]
my previous message is posted at
Posted: 10 December 2010 03:18 AM

that not true! No in the Netherlands it is: 10:20 hours!




Theme © iAndrew 2016 - Forum software by © MyBB