Category Archives: get primary key name

Symfony2, Doctrine – get the primary key field name in controller

If you need the primary key name in the Symfony2 controller you can get in this way: public function setGridDataAction(Request $request) { $em = $this->getDoctrine()->getEntityManager(); $meta = $em->getClassMetadata(‘AcmeTestBundle:TestTable’); $sPrimaryKeyName =$meta->getSingleIdentifierFieldName(); //get primary key name $aAllField = $meta->getFieldNames(); //get all field … Continue reading

Posted in Doctrine, get all field name, get primary key name, Symfony2 | 3 Comments