php sqlstate 08001,php – SQLSTATE [08001]:[Microsoft] [SQL Server的ODBC驱动程序13] TCP提供程序:无法建立连接,因为目标计...

我的doctrine存储库代码不起作用,而我能够正常访问数据库并读取表数据.

我得到这个堆栈跟踪:

EntityManager->getRepository('AppBundle:Person') in src\AppBundle\Controller\PersonViewController.php (line 18)

public function indexAction(Request $request) {

$em = $this->getDoctrine()->getManager();

$repo = $em->getRepository('AppBundle:Person');

$persons = $repo->findAll();

dump($persons);

人物实体模型:

Person.php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**

* Class Person

* @Package AppBundle/Entity

*

* @ORM\Entity(repositoryClass="AppBundle\Repository\PersonRepository")

* @ORM\Table(name="[Person]")

*/

class Person {

/**

* @ORM\Column(type="integer")

* @ORM\Id

* @ORM\GeneratedValue(strategy="AUTO")

*/

protected $id;

/**

* @ORM\Column(type="string", length=4)

*/

protected $type;

}

如果这也是必要的,回购代码:

PersonRepository.php

namespace AppBundle\Repository;

use /** @noinspection PhpUndefinedClassInspection */

Doctrine\ORM\EntityRepository;

class PersonRepository extends EntityRepository {

public function create() {

$entity = new Person();

$entity->type('WM_B');

$this->_em->persist($entity);

$this->_em->flush();

}

}

解决方法:

Sql Server配置管理器 – > Sql Server网络配置 – >协议 – > TCP / IP – >

我改变了以下内容

IpAll

TCP Dynamic Ports 49226

TCP Port

至:

IpAll

TCP Dynamic Ports

TCP Port 1433

不确定TCP动态端口是什么以及它们的配置原因.

标签:php,symfony,doctrine-orm

来源: https://codeday.me/bug/20190722/1501088.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值