tags:

views:

34

answers:

2

So on my test machine, I had PHP installed with Apache, and I had the PHP SQL Driver (not the Microsoft one). So, I used mssql_connect() and such commands to deal with the database.

When I shifted to another server, it has Microsoft PHP SQL Driver. Now it is crashing and showing me error of PHP_via_FastCGI error, whenever I execute the mssql_connect() and the other mssql_ php commands.

Could you please advise on how to solve this? Do I need to change my code to something else? If that is the case, I have hundreds of files, do I need to change in each?

Thanks.

+1  A: 

Those two drivers have nothing in common (apart from allowing to interact with SQL Server). They have different function names and functionality. Your program requires the PHP SQL Driver and will not run with the Microsoft one unless you completely rewrite it.

(Whatever, the Microsoft library is pretty good.)

Álvaro G. Vicario
+1  A: 

You will need to map (change) all the DB calls in the application to the Microsoft driver's equiv functions or create an abstraction layer. An abstraction layer is where you make up your own db functions like: myConnect(...) myEXEC(...)

and within that you have code like

if ($givenDriver=='M') { 
    code using microsoft DB function 
} elseif ($givenDriver=='P') { 
    code using the PHP DB function 
} else { 
    error unknown connection type
}

then everywhere in your code convert from the actual PHP driver commands to your abstraction layer commands. Then the code can easily switch between using one driver or another by changing the value of $givenDriver.

KM
PDO is a pretty good database abstraction layer, and it comes with PHP. It might be a good idea for johnshaddad to build his mssql conversion layer on top of that, just in case he ever needs to switch to a different database driver again.
James
Please note that the PDO driver for SQL Server is tagged as **experimental** and has actually been removed from latest PHP releases. A rewrite based upon PDO must use ODBC or the Microsoft driver.
Álvaro G. Vicario