SQLSTATE [08001]:[Microsoft] [SQL Server的ODBC驱动程序13] TCP提供程序:无法建立连接,因为目标计算机主动拒绝它

rms*_*ers 3 php symfony doctrine-orm

我的教训库代码不能正常工作,而我能够访问数据库和正常读取表数据.

我得到这个堆栈跟踪:

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);
Run Code Online (Sandbox Code Playgroud)

人物实体模型:

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;
}
Run Code Online (Sandbox Code Playgroud)

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

PersonRepository.php

<?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();
    }
}
Run Code Online (Sandbox Code Playgroud)

rms*_*ers 13

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

我改变了以下内容

IpAll
TCP Dynamic Ports 49226
TCP Port
Run Code Online (Sandbox Code Playgroud)

至:

IpAll
TCP Dynamic Ports
TCP Port          1433
Run Code Online (Sandbox Code Playgroud)

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