php - insertion values in database using symfony2 -


i want insert values in table doesn't work me, should do?

class defaultcontroller extends controller {   public function indexaction($name)   {     return $this->render('myapplibrarybundle:default:index.html.twig', array('name' => $name));   }    public function createaction()   {     $product = new product();     $product->setname('a foo bar');     $product->setprice('19.99');     $product->setdescription('lorem ipsum dolor');      $em = $this->getdoctrine()->getmanager();     $em->persist($product);     $em->flush();      return new response('id du produit créé : '.$product->getid());   } } 

one possible source of error product entity cannot found controller. adding use myapplibrarybundle\entity\product; statement (assuming in path) entity can found. if not answer, please post error message(s) receive.

//with line: use myapplibrarybundle\entity\product;  class defaultcontroller extends controller { ....  public function createaction() {     $product = new product();     $product->setname('a foo bar');     $product->setprice('19.99');     $product->setdescription('lorem ipsum dolor');      $em = $this->getdoctrine()->getmanager();     $em->persist($product);     $em->flush();      return new response('id du produit créé : '.$product->getid()); }  } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -