[英]Impossible to access an attribute (“nom_entite”) on a string variable ("Showig Array
我想從我的實體“實體”中獲取所有元素的列表。
我在我的存儲庫中:
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的元素列表,我想在表中獲取。
任何幫助,請!
在存儲庫中:
public function findAll(){
$stmt = $this->getEntityManager()
->getConnection()
->prepare('select * from Entite ');
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.