我的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