3

I have searched the site and the web for a PROPER tutorial on how to connect from your WAMP PHP to a local SQL SERVER without success.

Articles I have found on this site are:

None of them really help me.

Can someone post a proper article on how to connect from WAMP PHP to a local SQL Server with Windows Authentication. Also if possible with SQL server authentication.

I have tried installing php_pdo_mssql, php_mssql, extensions but I am getting unable to connect to server errors. I can connect to the server through SQL Server management studio when I just type Database name: DEV-13 and put Windows Authentication as login credentials.

A tutorial to for installing PHP extensions and connecting to sql server for dummies would be perfect!

Please help.

Community
  • 1
  • 1
C0D3
  • 6,440
  • 8
  • 43
  • 67

3 Answers3

1

Here is a guide from Microsoft. http://msdn.microsoft.com/en-us/library/cc296205%28v=sql.90%29.aspx

jarchuleta
  • 1,231
  • 8
  • 10
1

Are you wanting to connect using the identity that Apache is running as, or a different user? If the same user as Apache, see http://msdn.microsoft.com/en-us/library/cc793139(v=sql.90).aspx . Am looking for another article now as to how to use arbitrary credentials.

Also, mssql_* is in my mind deprecated. It's a pain to find the right DLLs for it, and it's not very well supported (though one of the only options on Linux).

I suggest using sqlsrv through PDO. That way you get the benefits of the newest (Microsoft supported) connection method, and worst case if you have to change back to mssql_* drivers, you can just change the PDO connection string and be done (no query changes or anything).

Corbin
  • 33,060
  • 6
  • 68
  • 78
  • Thanks I'll try this out and get back to your post and the identity doesn't matter in my case I guess. Though I will deploy this website to a different machine eventually. – C0D3 Mar 29 '12 at 19:35
  • 1
    I've looked around quite a bit, and as I can tell, there's no way to do Windows Authentication through the native client (the PHP hook-in anyway) other than the user Apache is running as. I haven't used the mssql_* extension in probably 5 years, so I don't know if it's the same case with that. If I were you, I'd be tempted to just use SQL Server authentication. Though I suppose if mssql_* does support it, you could use it. You could still use PDO, and then if you ever ran into problems, you could switch to sqlsrv worst case. – Corbin Mar 29 '12 at 19:38
  • Yeah, I'll try to get it to work with PDO for sure. Surprised PHP didn't provide a data access layer before. I think PDO just came with PHP 5? – C0D3 Mar 29 '12 at 19:39
  • It is indeed PHP >= 5.0. PHP < 5.0 was a horrid little language with horrible performance and OOP support. PDO requires certain OOP features that weren't existent or performant enough in PHP 4 :). – Corbin Mar 29 '12 at 19:41
  • If you mean an ORM, that would be quite difficult. A uniform connection/querying interface that is procedural already exists through in odbc_*. It's not DB agnostic as most ORM or DBALs are though because it still deals with raw SQL. :) – Corbin Mar 29 '12 at 19:48
0

this one: http://www.davidlauzon.net/2009/02/ms-sql-server-2008-with-php/ ?

Jerome Ansia
  • 6,854
  • 11
  • 53
  • 99