我的学说存储库代码不起作用,而我我能够正常访问数据库并读取表数据。
我得到了这个堆栈跟踪:
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
<?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();
}
}
答案 0 :(得分:10)
Sql Server配置管理器 - &gt; Sql Server网络配置 - &gt;协议 - &gt; TCP / IP - &gt;
我更改了以下内容
IpAll
TCP Dynamic Ports 49226
TCP Port
要:
IpAll
TCP Dynamic Ports
TCP Port 1433
不确定TCP动态端口是什么以及它们的配置原因。
答案 1 :(得分:0)
对于 SQL Server 2019 Developer
在默认安装中:
修复
要启用TCP / IP:
Start Menu
-> Microsoft SQL Server 2019
-> SQL Server 2019 Configuration Manager
-> SQL Server Network Configuration
-> Protocols For MSSQLSERVER
-> TCP/IP
-> Enable
启用SQL身份验证模式:
Start Menu
-> Microsoft SQL Server Tools
-> Microsoft SQL Server Management Studio
-> Right-Click the server node
-> Properties
-> Security
-> Under Authentication choose "SQL Server and Windows Authentication Mode"