我想获取实体中所有元素的列表" Entite"。
我在我的存储库中:
public function findAll(){
$stmt = $this->getEntityManager()
->getConnection()
->prepare('select * from Entite ');
$stmt->execute();
$result = $stmt->fetchAll();
return ( array('name' => 'Showig '. print_r($result,true)));
}
在我的控制器中:
public function listAction(){
$manageur = $this->getDoctrine()->getManager();
$listEntite = $manageur->getRepository("acmeBundle:Entite")->findAll();
return $this->render("acmeBundle:admin:listBu.html.twig",array("liste"=>$listEntite));
}
在我的树枝上我有这个:
{% for entite in liste %}
<tr> <td> {{ entite.nom_entite ~ " " }} </td> </tr>
<tr> <td> {{ entite.nom_agence ~ " " }} </td> </tr>
<tr> <td> {{ entite.entite_abrev ~ " " }} </td> </tr>
<tr> <td> {{ entite.entite_niveau ~ " " }} </td> </tr>
{% endfor %}
我得到了这个例外:
Impossible to access an attribute ("nom_entite") on a string variable ("Showig
Array
(
[0] => Array
(
[id] => 1
[nom_entite] => llll
[nom_agence] => 0
[entite_abrev] => fff
[entite_niveau] => 1
)
[1] => Array
(
[id] => 2
[nom_entite] => ffff
[nom_agence] => AG_22
[entite_abrev] => ffff
[entite_niveau] => 2
)
它是Entite的元素列表,我希望在表中得到它。
请帮助!
答案 0 :(得分:0)
:
public function findAll(){
$stmt = $this->getEntityManager()
->getConnection()
->prepare('select * from Entite ');
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}