Для этого расширения требуется драйвер Microsoft ODBC 11 для SQL Server для связи с SQL Server


Уже скачал sqlsrv в Microsoft...

enter image description here

И на моем phpinfo()

enter image description here

enter image description here

Включено на php.ini как на C:\wamp\bin\apache\apache2.4.9\bin, так и на C:\wamp\bin\php\php5.5.12 enter image description here

И все равно получил такую ошибку.

Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 

И мой код

try {
    $dbh = new PDO ("sqlsrv:Server=$host;Database=$db","$user","$pass");
  } catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
  }
  $stmt = $dbh->prepare("select top 5 from teams");
  $stmt->execute();
  while ($row = $stmt->fetch()) {
    print_r($row);
  }
  unset($dbh); unset($stmt);
Author: Storm Spirit, 2015-12-21

1 answers

Помимо расширения pdo_sqlsrv на вашем компьютере также должен быть установлен драйвер ODBC 11.

Вы можете получить его здесь: https://www.microsoft.com/en-us/download/details.aspx?id=36434

 24
Author: Mark, 2015-12-21 17:31:27