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();
}
}
我不知道與此問題。我的其他編碼,這種方式工作正常,但我很困惑,當這種方法不能用於我的編碼。
尼斯,有用。感謝您的幫助 。 –
沒問題:)高興地幫忙。不知道誰低估了你,似乎有點不合理,因爲你的問題對我來說似乎很好。 –
對不起,我的英語不太好。 –