Laravel 5.7-Windows 2012 R2-XAMPP 7.2-SQLSRV 11.0无法正常工作

时间:2018-11-21 10:14:42

标签: sqlsrv laravel-5.7

我已经用以下代码检查了我的php配置:

<?php

$tsql = "SELECT id FROM tbl1";  

$conn = sqlsrv_connect( 'localhost', ["Database"=>"lv_detritus", "UID"=>"laravel_user", "PWD"=>"euldlm1605"]);

$getData = sqlsrv_query($conn, $tsql);

while ($id = sqlsrv_fetch_array($getData, SQLSRV_FETCH_ASSOC)) {
    echo $id['id'];
}
sqlsrv_free_stmt($getData);

$conn_pdo = new PDO("sqlsrv:Server=localhost;Database=lv_detritus", "laravel_user", "euldlm1605");

$getData_pdo = $conn_pdo->prepare($tsql);  
$getData_pdo->execute();  
$ids_pdo = $getData_pdo->fetchAll(PDO::FETCH_ASSOC);

echo '<br/>';
foreach ($ids_pdo as $id_pdo) {
    echo $id_pdo['id'];
}

?>

并且运行正常(两次显示12345就是我表上的数据)。

然后配置一个新的laravel项目/.env:

DB_CONNECTION=sqlsrv
DB_HOST=localhost
DB_PORT=1433
DB_DATABASE=lv_detritus
DB_USERNAME=laravel_user
DB_PASSWORD=*****

但是当尝试运行php artisan migration时:

Illuminate \ Database \ QueryException:找不到驱动程序(SQL:从类型='U'并且名称= migrations的sysobjects中选择*)

在W:\ laravelapps \ proves \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:664

(我也尝试使用服务器的IP,IP \ instance,但仍然出现相同的错误)

有人可以帮我吗?

谢谢!

0 个答案:

没有答案