Preferred MS SQL Access Method with PHP 5.3+ on Linux

What is the preferred method of accessing a Microsoft SQL Server database with PHP 5.3+ on Linux?

Given the various extension options available, I'm not sure which method is preferable based on reliability and performance. Right now I am using the mssql extension using FreeTDS, but I would like to know if this is not the best.

I heard some of them recommend using php-odbc / EasySoft because the mssql extension was abandoned, but others said the ODBC transition was not worth the performance hit.

The answer to this stackoverflow question seems to affect what I am asking, however it is Windows oriented.

Thanks!

+8
linux database php sql-server
source share
2 answers

I had good results using the PHP PDO library (PHP Data Objects) for this kind of thing. There's a great tutorial at http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/ . Just make sure you use the following template to initialize the database connection:

$dbh = new PDO("dblib:host=$host;dbname=$dbname", $user, $pass); 
+1
source share

I am using FreeTDS. This is far from satisfactory. In fact, I found your question because I live in the hope that there should be a better solution, and I continue to look for it. Unfortunately, FreeTDS seems to be the best option at the moment if you are working in a Linux environment.

If you were on Windows, you could probably use Microsoft SQL Server drivers for PHP, which would be better, but even then there are missing features like PDO support lastInsertId() .

0
source share

All Articles