【发布时间】:2016-03-12 10:43:33
【问题描述】:
Symfony 现在正在折磨我。我正在尝试从表中获取数据,其中列将关系与另一个表中的 id 相关联。这就是我的控制器功能:
/**
* @Route("/proposta/{id}", defaults={"id"=null})
*/
public function mostraAction($id) {
$model = $this->getDoctrine()->getManager();
$lista = $model->getRepository('AppBundle:Propostes')->find($id);
$em = $this->getDoctrine()->getManager();
$listaVotacions = $em->getRepository('AppBundle:Votacions')->findByIdProposta($id);
return $this->render(':Proposta:index.html.php',
array('lista'=>$lista,'listaVotacions'=>$listaVotacions));
}
那不行,当我执行这个函数时,我的服务器掉了,我得到这个错误:
[ERROR] Built-in server terminated unexpectedly.
这是我的职业类别:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Votacions
*
* @ORM\Table(name="votacions")
* @ORM\Entity(repositoryClass="AppBundle\Repository\VotacionsRepository")
*/
class Votacions
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Propostes")
*/
private $idProposta;
/**
* @ORM\ManyToOne(targetEntity="Usuaris")
*/
private $idUsuari;
/**
* @var bool
*
* @ORM\Column(name="vot", type="boolean", nullable=true)
*/
private $vot;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set idProposta
*
* @param integer $idProposta
*
* @return Votacions
*/
public function setIdProposta($idProposta)
{
$this->idProposta = $idProposta;
return $this;
}
/**
* Get idProposta
*
* @return int
*/
public function getIdProposta()
{
return $this->idProposta;
}
/**
* Set idUsuari
*
* @param integer $idUsuari
*
* @return Votacions
*/
public function setIdUsuari($idUsuari)
{
$this->idUsuari = $idUsuari;
return $this;
}
/**
* Get idUsuari
*
* @return int
*/
public function getIdUsuari()
{
return $this->idUsuari;
}
/**
* Set vot
*
* @param boolean $vot
*
* @return Votacions
*/
public function setVot($vot)
{
$this->vot = $vot;
return $this;
}
/**
* Get vot
*
* @return bool
*/
public function getVot()
{
return $this->vot;
}
}
这是我的存储库 Votacions:
namespace AppBundle\Entity;
use Doctrine\ORM\EntityRepository;
class VotacionsRepository extends EntityRepository
{
public function findByIdProposta($id)
{
return $this->getEntityManager()
->createQuery(
'SELECT * FROM AppBundle:Votacions WHERE idProposta ='.$id
)->getResult();
}
}
有人可以帮助我:(?
非常感谢。
卡尔斯
【问题讨论】:
标签: php mysql symfony orm doctrine-orm