PHP with SQL Server 2005+

We currently have a hybrid ASP / PHP installation that connects to the SQL Server 2005 database. But all the work with queries is done on the client side, I would like to move some of this to PHP.

What driver and / or connection string are required to connect to Sql Svr and what is the syntax for use in PHP?


Update: OK, so I definitely tried to avoid using any actions with copying DLLs, etc. I will review SQL2K5PHP (thanks Vincent). @jcarrascal for clarity, the "client side". I mean, our application is an internal web application that runs as an HTA , with all requests made using javascript calls in ASP, which actually sends the database request.

+3
source share
3 answers

You have two options:

1) php_mssql extension . If you want the same mysql and mysqli APIs, use the php_mssql extension. But there is a catch, the associated ntwdblib.dll file with PHP does not work. You must find this file from a SQL Server 2000 installation or find it on the Internet. This API is supposedly not very reliable, but I used it without problems for about a year.

http://ca.php.net/mssql

2) PHP driver Microsoft SQL Server 2005 . If you want something more modern, but which does not have the same API and lacks some important functions (mssql_num_rows). The big plus is that it is supported by Microsoft and is likely to work with a future version.

http://msdn.microsoft.com/en-us/data/cc299381.aspx

+5

mssql_connect() :

$conn = mssql_connect('localhost', 'sa' , '123456')
    or die('Can\'t connect.');
mssql_select_db('database', $conn)
    or die('Can\'t select the database');

, SQL Server, PHP MSSQL.

, , " " WTF?: D

+2

PHP provides an extension to access Microsoft SQL Server databases. To use the SQL Server extension, all that is required is to activate the extension in the PHP configuration file.

Details of the MSDN Page

0
source

Source: https://habr.com/ru/post/1696481/


All Articles