简体   繁体   English

主义找不到驱动程序pdo_sqlsrv [Windows]

[英]Doctrine can't find driver pdo_sqlsrv [Windows]

I am building a website in symphony and I am required to use Windows 7 and SQL server 2014 for it. 我正在用交响乐建立网站,并且需要使用Windows 7和SQL Server 2014。 (I'm using php 5.6 in wamp server x64) (我在Wamp Server x64中使用php 5.6)

I've already checked other similar questions like: Cannot find driver pdo_sqlsrv but they seem not to work and most others are based around the linux version. 我已经检查了其他类似的问题,例如: 找不到驱动程序pdo_sqlsrv,但它们似乎不起作用,并且大多数其他驱动程序都基于linux版本。

into the config.yml of symfony I put: 放入symfony的config.yml中:

# Doctrine Configuration
doctrine:
   dbal:
       driver: pdo_sqlsrv

Currently when I try to run 目前,当我尝试跑步时

php bin/console doctrine:database:create

from the root folder of my project it gives me the following: 从我项目的根文件夹中,它可以为我提供以下信息:

[Doctrine\\DBAL\\Driver\\PDOException] [Doctrine \\ DBAL \\ Driver \\ PDOException]
could not find driver 找不到驱动程序
[PDOException] [PDOException]
could not find driver 找不到驱动程序

I've checked and upon running a simple query in a test file directly onto pdo it works and is also listed with the pdo drivers as [0]=>sqlsrv 我已经检查过,在测试文件中直接在pdo上直接运行简单查询后,它就可以工作,并且在pdo驱动程序中也列为[0] => sqlsrv

As a note the drivers provided by Windows did not work as expected but instead http://robsphp.blogspot.mx/2012/06/unofficial-microsoft-sql-server-driver.html this ones did. 请注意,Windows提供的驱动程序未按预期运行,而是运行了http://robsphp.blogspot.mx/2012/06/unofficial-microsoft-sql-server-driver.html

Well I managed to find the solution. 好吧,我设法找到了解决方案。 First off to stop using apache as the server and instead work with IIS. 首先,停止使用apache作为服务器,而改为使用IIS。 This solved the problem of the drivers from Microsoft not working. 这解决了Microsoft驱动程序无法正常工作的问题。

The next problem was that the connection to the database was rejected constantly. 下一个问题是与数据库的连接一直被拒绝。 That was solved by enabling TCP IP and assigning a port to IPALL 通过启用TCP IP并将端口分配给IPALL可以解决此问题

Hopefully this will be useful to someone. 希望这对某人有用。

My solution to this was to call doctrine directly from the fully qualified path to php install. 我的解决方案是直接从完全合格的php路径调用doctrine。 WAMP doesn't want your php versions in PATH, but you need to be able to reach those for doctrine to work, so I do WAMP不想在PATH中使用您的php版本,但是您需要能够使这些版本起作用,所以我可以

from project directory: 从项目目录:

cd c:\symfony\myProject\
c:\wampsrvr\bin\php\php7.2.4\php bin\console doctrine:schema:update --force

on mac, it's just bin\\console doctrine:schema:update --force 在Mac上,这只是bin \\ console指令:schema:update --force

but due to WAMP's weird thing, I had to call it like this. 但是由于WAMP的怪异,我不得不这样称呼它。 It might not be the perfect solution but I hope it helps. 这可能不是一个完美的解决方案,但我希望它会有所帮助。 You could make a BAT to the PHP and put that in a shared PATH too. 您可以将BAT制作到PHP,并将其放在共享的PATH中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM