我在编码方面遇到了问题。当我发送表单并保存到数据库时,会出现以下类似的消息:
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();
}
}
我想知道这个问题属于哪类。我的其他代码可以正常运行,但是当我在这段代码中使用这种方法时出现了困惑。