【发布时间】:2015-04-15 12:52:33
【问题描述】:
我正在尝试使用服务在表中创建行。但它说在非对象上调用成员函数 setFirstname(),这是行:
$this->idm->setPersno($science->getPersno());
我在谷歌上搜索了几个小时,但找不到该问题的解决方案。有人可以帮帮我吗?
$scienceList = $this->em->getRepository('MyBundle:MyTable1')->findAll();
foreach ($scienceList as $science)
{
$idm = new Users();
$this->idm = $this->em->getRepository('MyBundle:MyOtherTable')->find($science->getPersno());
if($this->idm == null)
{
$this->idm->setPersno($science->getPersno());
$this->idm->setFirstname($science->getFirstname());
$this->idm->setLastname($science->getLastname());
$this->em->persist($idm);
}
}
$this->em->flush();
【问题讨论】:
标签: symfony service doctrine entity