我试图在我的控制器中访问 getName(),但它不起作用。
这不起作用:
$supplier = $em->getRepository('WICSupplierBundle:Supplier')->findBy(array('account'=>$account_id, 'id'=>$id));
$supplierName = $supplier->getName();
This doesnt return the name from the db....
I get the error: "Error: Call to a member function getName() on a non-object..."
这确实有效:
$supplier = $em->getRepository('WICSupplierBundle:Supplier')->find($id);
$supplierName = $supplier->getName();
This returns the name from the db....
为什么?