2013-10-06 87 views
0

幫我如何獲取所有材料的ID?

public function indexAction() 
{ 


$tpos = $this->getDoctrine()->getRepository('TestBundle:Materials')->findAll(); 

foreach($tposs as $tpos) { 
    $posts['id']; 
} 

echo $midcount; 

怎麼你願意嗎?

注意:未定義指數:ID

回答

1
$materials = $this->getDoctrine()->getRepository('TestBundle:Materials')->findAll(); 
$materialIds = array(); 
foreach ($materials as $material) { 
    $materialIds[] = $material->getId(); 
} 
+0

你想幹什麼? – zapcost