PHP to SQL Server without ODBC or MSSQL support

前端 未结 1 1731
清酒与你
清酒与你 2020-12-21 02:00

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 change that, so I\'m wondering if

相关标签:
1条回答
  • 2020-12-21 02:49

    Found the solution:

    http://www.php.net/manual/en/ref.mssql.php#42696

    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(); 
    } 
    ?> 
    
    0 讨论(0)
提交回复
热议问题