小编Agu*_*bat的帖子

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
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)

我不知道与哪个问题有关。我的另一种编码方式很好用,但是当我无法在此编码中使用此方法时,我感到困惑。

set symfony

5
推荐指数
1
解决办法
7610
查看次数

如何在Controller中包含任何php

我想在控制器内调用一个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)

如果有人可以帮助我?谢谢

php controller include symfony

4
推荐指数
1
解决办法
373
查看次数

标签 统计

symfony ×2

controller ×1

include ×1

php ×1

set ×1