帮帮我
public function indexAction()
{
$tpos = $this->getDoctrine()->getRepository('TestBundle:Materials')->findAll();
foreach($tposs as $tpos) {
$posts['id'];
}
echo $midcount;
你会怎么做?
注意:未定义索引:id
答案 0 :(得分:1)
$materials = $this->getDoctrine()->getRepository('TestBundle:Materials')->findAll();
$materialIds = array();
foreach ($materials as $material) {
$materialIds[] = $material->getId();
}