Fatal error: Call to undefined method in view
Fatal error: Call to undefined method in view
当我尝试从 JoinColumns 获取结果时,视图出现错误。这是控制器中的一个查询
public function indexAction()
{
$users = $this->getEntityManager()
->getRepository('\ApanelUsers\Entity\Usercommon')
->findAll();
$viewModel = new ViewModel(['users' => $users]);
return $viewModel;
}
这是实体代码的一部分
/**
* @var integer
*
* @ORM\Column(name="UserId", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $userid;
/**
* @var string
*
* @ORM\Column(name="UserEmail", type="string", length=100, precision=0, scale=0, nullable=false, unique=false)
*/
private $useremail;
/**
* @var string
*
* @ORM\Column(name="UserFirstName", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $userfirstname;
/**
* @var \ApanelUsers\Entity\Userstatus
*
* @ORM\ManyToOne(targetEntity="ApanelUsers\Entity\Userstatus")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="User_StatusId", referencedColumnName="UserStatusId", nullable=false)
* })
*/
private $userStatusid;
这是我的看法
<td>
<?= $user->getUserFirstName(); ?>
</td>
<td>
<?= $user->getUserEmail(); ?>
</td>
当我尝试获取 <?= $user->getUser_StatusId(); ?>
时出现错误:
Fatal error: Call to undefined method ApanelUsers\Entity\Usercommon::getUser_StatusId() in /home/xtadmin/localhost/panorama-hotel.local/www/module/ApanelUsers/view/apanel-users/index/index.phtml on line 52
--|更新 |--
我已经更改了 Doctrine 生成的实体文件,所以我有:
实体
/**
* @var \ApanelUsers\Entity\Userstatus
*
* @ORM\ManyToOne(targetEntity="ApanelUsers\Entity\Userstatus")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="User_StatusId", referencedColumnName="UserStatusId", nullable=false)
* })
*/
private $userStatusid;
/**
* Set userStatusid
*
* @param \ApanelUsers\Entity\Userstatus $userStatusid
* @return Usercommon
*/
public function setUserStatusid(\ApanelUsers\Entity\Userstatus $userStatusid = null)
{
$this->userStatusid = $userStatusid;
return $this;
}
/**
* Get userStatusid
*
* @return \ApanelUsers\Entity\Userstatus
*/
public function getUserStatusid()
{
return $this->userStatusid;
}
index.phtml
<?= $user->getUserStatusid(); ?>
而我钢有误
Catchable fatal error: Object of class DoctrineORMModule\Proxy__CG__\ApanelUsers\Entity\Userstatus could not be converted to string in /home/xtadmin/localhost/panorama-hotel.local/www/module/ApanelUsers/view/apanel-users/index/index.phtml on line 27
问题是您调用的方法 "getUser_StatusId()" 带有这个下划线,但它是在没有下划线的情况下定义的 "getUserStatusId()"
当我尝试从 JoinColumns 获取结果时,视图出现错误。这是控制器中的一个查询
public function indexAction()
{
$users = $this->getEntityManager()
->getRepository('\ApanelUsers\Entity\Usercommon')
->findAll();
$viewModel = new ViewModel(['users' => $users]);
return $viewModel;
}
这是实体代码的一部分
/**
* @var integer
*
* @ORM\Column(name="UserId", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $userid;
/**
* @var string
*
* @ORM\Column(name="UserEmail", type="string", length=100, precision=0, scale=0, nullable=false, unique=false)
*/
private $useremail;
/**
* @var string
*
* @ORM\Column(name="UserFirstName", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
*/
private $userfirstname;
/**
* @var \ApanelUsers\Entity\Userstatus
*
* @ORM\ManyToOne(targetEntity="ApanelUsers\Entity\Userstatus")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="User_StatusId", referencedColumnName="UserStatusId", nullable=false)
* })
*/
private $userStatusid;
这是我的看法
<td>
<?= $user->getUserFirstName(); ?>
</td>
<td>
<?= $user->getUserEmail(); ?>
</td>
当我尝试获取 <?= $user->getUser_StatusId(); ?>
时出现错误:
Fatal error: Call to undefined method ApanelUsers\Entity\Usercommon::getUser_StatusId() in /home/xtadmin/localhost/panorama-hotel.local/www/module/ApanelUsers/view/apanel-users/index/index.phtml on line 52
--|更新 |-- 我已经更改了 Doctrine 生成的实体文件,所以我有: 实体
/**
* @var \ApanelUsers\Entity\Userstatus
*
* @ORM\ManyToOne(targetEntity="ApanelUsers\Entity\Userstatus")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="User_StatusId", referencedColumnName="UserStatusId", nullable=false)
* })
*/
private $userStatusid;
/**
* Set userStatusid
*
* @param \ApanelUsers\Entity\Userstatus $userStatusid
* @return Usercommon
*/
public function setUserStatusid(\ApanelUsers\Entity\Userstatus $userStatusid = null)
{
$this->userStatusid = $userStatusid;
return $this;
}
/**
* Get userStatusid
*
* @return \ApanelUsers\Entity\Userstatus
*/
public function getUserStatusid()
{
return $this->userStatusid;
}
index.phtml
<?= $user->getUserStatusid(); ?>
而我钢有误
Catchable fatal error: Object of class DoctrineORMModule\Proxy__CG__\ApanelUsers\Entity\Userstatus could not be converted to string in /home/xtadmin/localhost/panorama-hotel.local/www/module/ApanelUsers/view/apanel-users/index/index.phtml on line 27
问题是您调用的方法 "getUser_StatusId()" 带有这个下划线,但它是在没有下划线的情况下定义的 "getUserStatusId()"