這是我的控制器一個例外模板的渲染過程中被拋出(「捕致命錯誤:類對象無法被轉換成字符串」)
public function personnePhysiqueDetailsAction($id)
{
$em = $this->getDoctrine()->getManager();
$controle = $this->get('Controles');
if(($controle->is_Granted('Afficher détail client','Client/Societaire',$this->getUser()))==false){throw new AccessDeniedException();}
// $listePersonnePhysiques=$personnePhysique = $em->getRepository('ITBundle:PersonnePhysique')->findAll();
$personnePhysique = $em->getRepository('ITBundle:PersonnePhysique')->find($id);
$adresses=$em->getRepository('ITBundle:Adresse')->findOneBy(array('personne'=>$personnePhysique));
$mails=$em->getRepository('ITBundle:Email')->findOneBy(array('personne'=>$personnePhysique));
$telephones=$em->getRepository('ITBundle:Telecom')->findBy(array('personne'=>$personnePhysique));
$contrat=$em->getRepository('ITBundle:Contrat')->findBy(array('souscripteur'=>$personnePhysique));
$branches = $em->getRepository('ITBundle:Branche')->findAll();
$compteBancaire=$em->getRepository('ITBundle:CompteBancaire')->findBy(array('personne'=>$personnePhysique));
$avenants=$em->getRepository('ITBundle:AvenantSignaletique')->findBy(array('personne'=>$personnePhysique));
$adresseHisto=$em->getRepository('ITBundle:AdresseHisto')->findBy(array('avenant'=>$avenants));
$compteHisto=$em->getRepository('ITBundle:CompteBancaireHisto')->findBy(array('avenant'=>$avenants));
$personnephysiquehisto=$em->getRepository('ITBundle:PersonnePhysiqueHisto')->findBy(array('avenant'=>$avenants));
$familles=$em->getRepository('ITBundle:Famille')->findBy(array('personne'=>$personnePhysique));
和THID是我的倉庫
public function PersonnePhysiqueDetail($id){
return $this->createQueryBuilder('p')
->select(' p.id, p.nom , p.prenom, p.cin, p.dateNaissance,p.sexe, s.libelle situation,s.id idSituation')
->innerJoin('p.situationFamiliale', 's')
->where('p.id = :idPersonne')
->setParameter('idPersonne', $id)
->getQuery()
->getResult();
}
在我的樹枝
{% for famille in familles %}
<tr>
<th>{{ famille.personne }}:</th>
</tr>
{% endfor %}
這是familles的declation在我的實體personne
/**
* @var array
* @ORM\OneToMany(targetEntity="IT\ITBundle\Entity\Famille",cascade={"persist","remove"}, mappedBy="personne")
* @ORM\JoinColumn(name="enfant_id", referencedColumnName="id")
*/
private $familles;
/**
* Add famille
*
* @param \IT\ITBundle\Entity\Famille $famille
*
* @return Personne
*/
public function addFamille(\IT\ITBundle\Entity\Famille $famille)
{
$this->familles[] = $famille;
return $this;
}
/**
* Remove famille
*
* @param \IT\ITBundle\Entity\Famille $famille
*/
public function removefamille(\IT\ITBundle\Entity\Famille $famille)
{
$this->familles->removeElement($famille);
}
/**
* Get familles
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getfamilles()
{
return $this->familles;
}
和我的彩實體
<?php
namespace IT\ITBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Famille
* @ORM\Table(name="famille")
* @ORM\Entity(repositoryClass="IT\ITBundle\Repository\FamilleRepository")
*/
class Famille
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="lien", type="string", length=255, nullable=true)
*/
private $lien;
/**
* @ORM\ManyToOne(targetEntity="IT\ITBundle\Entity\Personne", inversedBy="familles")
* @ORM\JoinColumn(name="personne_id", referencedColumnName="id")
* #var array
* #ORM\Column(name="personne_id", type="array")
*/
private $personne;
/**
* @var string
* @ORM\ManyToOne(targetEntity="IT\ITBundle\Entity\Personne", inversedBy="familles")
* @ORM\JoinColumn(name="enfant_id", referencedColumnName="id")
*/
private $enfant;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set lien
*
* @param string $lien
* @return Famille
*/
public function setLien($lien)
{
$this->lien = $lien;
return $this;
}
/**
* Get lien
*
* @return string
*/
public function getLien()
{
return $this->lien;
}
/**
* Set personne
*
* @param \IT\ITBundle\Entity\Personne $personne
*
* @return Personne
*/
public function setPersonne(\IT\ITBundle\Entity\Personne $personne = null)
{
$this->personne = $personne;
return $this;
}
/**
* Get personne
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getPersonne()
{
return $this->personne;
}
/**
* Set enfant
*
* @param \IT\ITBundle\Entity\Famille $enfant
*
* @return Personne
*/
public function setEnfant($enfant)
{
$this->enfant = $enfant;
return $this;
}
/**
* Get enfant
*
* @return Personne
*/
public function getEnfant()
{
return $this->enfant;
}
public function __construct()
{
$this->familles = new \Doctrine\Common\Collections\ArrayCollection();
}
}
我知道personne是一個數組,多數民衆贊成使問題 現在我想你syggestion請我怎樣才能讓我的樹枝「personne_nom」其中id(在personne)= enfant_id(以粉彩)
personne不是數組,是s的對象 –