I work primarly with PHP & MySQL, but I have a potential client with a MS SQL and ASP setup. Due to some complicated reasons and offline software integration, they need
Yes. As long as you have the php_mssql extension on your server, you can use the following common functions:
// Connect to mssql server
$handle = mssql_connect($host, $user, $pass) or die("Cannot connect to server");
// Select a database
$db = mssql_select_db($dn_name, $handle) or die("Cannot select database");
// Execute a query
$query = "SELECT * FROM users WHERE lname = 'Smith'";
$result = mssql_query($query);
// Iterate over results<br />
while($row = mssql_fetch_array($result)) {
echo $row["id"];
}
Note: From PHP 5.3 this extension is not included (and probably not maintained). You can download and add it manually, or better use Microsoft drivers.
yes you can connect to MsSQL . If you are using wamp then switch on the php extension php_mssql if not then use the php.ini file and modify it
You should take a look at those links : http://www.php.net/manual/en/ref.pdo-dblib.php and http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
Yes, Microsoft provides a MS SQL driver for PHP.
Or you can access it via OBDC (Given the solution would be deployed on windows).
http://www.microsoft.com/sqlserver/2005/en/us/php-driver.aspx
Yes, you can. It depends on which version of PHP you're using, but if you're using PHP5+ you can use Microsoft's SQL Server Driver for PHP. Make sure you use version 2, which gives you the PDO functionality as well as the procedural style.
You can also use the PDO ODBC driver to access a SQL Server instance, but that approach is more buggy and I don't recommend it.
Finally you can use the PHP MSSQL library but that's even worse. Go with Microsoft's own solution if you can.
Edit: Oh, and there's also the DBLIB MSSQL PDO driver - stay away from that one too!
For me the solution has been to install the MS drivers as indicated above, and use ADODB library as intermediate. I've had this in production in an intranet over IIS6 and latest MSSQLExpress for months without any issue, perfectly reliable.