3

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.

3
  • That's why you must always use a database abstraction library. Commented Sep 3, 2010 at 17:43
  • @shamittomar, database abstraction libraries solve a number of problems but not this specific one: whatever library you choose, you still need to have it installed. Commented Sep 3, 2010 at 19:44
  • @Álvaro G. Vicario, but if there was an abstraction layer, you'd just need to add support in the abstraction layer for the Microsoft driver. without and abstraction layer, the OP will need to touch every piece of code that deals with the DB, either converting the calls to the Microsoft format or by implementing an abstraction layer. Commented Sep 3, 2010 at 20:48

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.
1

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.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.