我在编码时遇到问题。当我向您发送表单并将其保存到数据库时,将显示如下消息:
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
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
$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();
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道与哪个问题有关。我的另一种编码方式很好用,但是当我无法在此编码中使用此方法时,我感到困惑。
我想在控制器内调用一个php文件,但它出现如下错误:
Fatal error: Class 'AppBundle\Controller\DOMPDF' not found in ....
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
require_once(__DIR__.'/../../../../dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream('report_'.$name.'.pdf');
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我?谢谢