[英]Doctrine configuration in Zend Framework 3
I am using Zend Framework 3 for my project. 我正在为我的项目使用Zend Framework 3。 I would like to use Doctrine with Sql Server 2014. When I use Zend-Db all things are fine but using Doctrine displays me this message:
我想将Doctrine与Sql Server 2014一起使用。当我使用Zend-Db时,一切都很好,但是使用Doctrine会显示以下消息:
Fatal error: Invalid handle returned. in C:\Users\root\zendwithsqlserver\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43
I have done all configurations needed for doctrine First I config my sql server database credentials in config/autoload/local like this: 我已经完成了学说所需的所有配置。首先,我在config / autoload / local中配置sql server数据库凭据,如下所示:
<?php
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSqlsrvDriver;
return array(
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' => PDOSqlsrvDriver::class,
'params' => [
'host' => 'localhost',
'user' => 'sa',
'password' => 'mypassword',
'dbname' => 'blog',
]
],
],
],
);
To finish in my module.config.php file located in module/Application/module/ I add the doctrine code to permit it to know where are situated my entities . 为了完成我位于module / Application / module /中的module.config.php文件,我添加了理论代码以使它知道我的实体在哪里。
'doctrine' => [
'driver' => [
__NAMESPACE__ . '_driver' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/Entity']
],
'orm_default' => [
'drivers' => [
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
]
]
]
]
I would like to know how can I fix this error?: 我想知道如何解决此错误?:
Fatal error: Invalid handle returned. in C:\Users\root\zendwithsqlserver\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43
Any idea or suggestion is welcome, thanks in advance. 欢迎任何想法或建议,谢谢。
Please change the local.php as below code. 请按以下代码更改local.php。
<?php
use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' => SQLSrvDriver::class,
'params' => [
'host' => 'USER-PC\MYINSTANCE',
'user' => 'sa',
'password' => 'mypassword',
'dbname' => 'blog',
'port' => '49166'
]
],
],
],
];
Please refer this link to find the mssql port number : Identify Port used by SQL Server Database Engine Using SQL Server Configuration Manager 请参考此链接以查找mssql端口号: 使用SQL Server配置管理器识别SQL Server数据库引擎使用的端口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.