4
中调用我在编码时遇到了问题。当我送你的形式,并保存到数据库中,类似这样的消息:Symfony2可捕捉的致命错误:参数1传递给...必须是...整数的一个实例,在
Catchable fatal error: Argument 1 passed to ITTBundle\Entity\Student::setFormClass() must be an instance of ITTBundle\Entity\FormClass, integer given, called in C:\Users\Rivan\Documents\DigitalSchoolBase\Symfony2\src\ITTBundle\Controller\ConfigureController.php on line 601 and defined in C:\Users\Rivan\Documents\DigitalSchoolBase\Symfony2\src\ITTBundle\Entity\Student.php on line 901
这里是我的代码:
$findclass = $this->getDoctrine()
->getRepository('ITTBundle:FormClass')
->findOneBy(array('class_level' => $classlevel->getId(), 'letter' => $letter, 'class_major' => $classmajor->getId()));
//print_r($findclass->getId()); exit;
if(empty($error_message))
{
If ($findclass)
{
$em = $this->getDoctrine()->getManager();
$students->setFormClass($findclass->getId());
$em->persist($students);
$em->flush();
}
}
我不知道与此问题。我的其他编码,这种方式工作正常,但我很困惑,当这种方法不能用于我的编码。
尼斯,有用。感谢您的帮助 。 –
没问题:)高兴地帮忙。不知道谁低估了你,似乎有点不合理,因为你的问题对我来说似乎很好。 –
对不起,我的英语不太好。 –