1

当我从我的实体"EcoliaFrontBundle:UserEvaluation"发出请求 DQL 时遇到问题。它是 "EcoliaUserBundle:User" 和"EcoliaFrontBundle:UserEvaluation"之间的关系。错误是:Ecolia/FrontBundle/User类不存在。

错误图片:http: //img405.imageshack.us/img405/5461/sanstitre1cbz.jpg

我有 3 个捆绑包:

  1. 行政
  2. 正面
  3. 用户

这是代码UserEvaluation

    <?php

namespace Ecolia\FrontBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Ecolia\UserBundle\Entity\User;
use Ecolia\FrontBundle\Entity\Evaluation;

/**
 * Ecolia\FrontBundle\Entity\UserEvaluation
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class UserEvaluation
{
    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Ecolia\FrontBundle\Entity\Evaluation")
     */
    private $evaluation;

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Ecolia\UserBundle\Entity\User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    private $user;

    /**
     * @var float $note
     *
     * @ORM\Column(name="note", type="float")
     */
    private $note;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set note
     *
     * @param float $note
     */
    public function setNote($note)
    {
        $this->note = $note;
    }

    /**
     * Get note
     *
     * @return float 
     */
    public function getNote()
    {
        return $this->note;
    }

    /**
     * Set evaluation
     *
     * @param Ecolia\FrontBundle\Entity\Evaluation $evaluation
     */
    public function setEvaluation(\Ecolia\FrontBundle\Entity\Evaluation $evaluation)
    {
        $this->evaluation = $evaluation;
    }

    /**
     * Get evaluation
     *
     * @return Ecolia\FrontBundle\Entity\Evaluation 
     */
    public function getEvaluation()
    {
        return $this->evaluation;
    }


    /**
     * Set user
     *
     * @param Ecolia\UserBundle\Entity\User $user
     */
    public function setUser(\Ecolia\UserBundle\Entity\User $user)
    {
        $this->user = $user;
    }

    /**
     * Get user
     *
     * @return Ecolia\UserBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }
}

这是代码评估:

<?php

namespace Ecolia\FrontBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Ecolia\FrontBundle\Entity\Evaluation;
use Ecolia\FrontBundle\Entity\UserEvaluation;
use Ecolia\FrontBundle\Entity\Grade;
use Ecolia\FrontBundle\Entity\UserGrade;
use Ecolia\UserBundle\Entity\User;
//use Ecolia\FrontBundle\Form\NewsType;
// N'oubliez pas de rajouter le ArticleHandler
//use Ecolia\FrontBundle\Form\NewsHandler;


class EvaluationController extends Controller
{
    public function indexAction() {
        $repos_grades = $this->getDoctrine()->getEntityManager()->getRepository('EcoliaFrontBundle:Grade');
        $query = $repos_grades->createQueryBuilder('g')
                            ->getQuery();

        $grades = $query->getResult();
        return $this->render('EcoliaFrontBundle:Evaluation:index.html.twig', array('grades' => $grades));
    }

    public function gradeAction($idClass) {
        $em = $this->getDoctrine()->getEntityManager();
        $dql = "SELECT u 
                FROM EcoliaFrontBundle:UserGrade ug,  
                EcoliaUserBundle:User u 
                WHERE ug.user = u 
                AND ug.grade = :id";
        $query = $em->createQuery($dql)->setParameter('id', $idClass);

        $students = $query->getResult();

        return $this->render('EcoliaFrontBundle:Evaluation:grade.html.twig', array('students' => $students));
    }

    public function studentAction($id) {
        $em = $this->getDoctrine()->getEntityManager();
        $dql = "SELECT u, ue 
                FROM EcoliaFrontBundle:UserEvaluation ue,  
                EcoliaUserBundle:User u 
                WHERE ue.user = u 
                AND u.id = :id";
        $query = $em->createQuery($dql)->setParameter('id', $id);

        $studentsEval = $query->getResult();

        var_dump($studentsEval);

        return $this->render('EcoliaFrontBundle:Evaluation:student.html.twig', array('students' => $studentsEval));
    }


}
4

0 回答 0