I'm in a situation where my Windows hosting has PHP support, but the PHP is not configured to support ODBC or MSSQL. I can't get them to c开发者_如何转开发hange that, so I'm wondering if there's a way to connect to SQL Server through other means - maybe including some files that provide the functions that I'd need?
Leaving it up here in the hopes that it will make it easier for other people to get around this type of limitation.
Copied here for completeness:
<?php
$db = new COM("ADODB.Connection");
$dsn = "DRIVER={SQL Server}; SERVER={SERVER};UID={USER};PWD={PASS}; DATABASE={DB}";
$db->Open($dsn);
$rs = $db->Execute("SELECT * FROM table");
while (!$rs->EOF)
{
echo $rs->Fields['column']->Value."<BR>";
$rs->MoveNext();
}
?>
精彩评论