php - how i save data in zf2 using mongoodm? -


I am creating a controller in zf2 to save data in mongodb, but this does not save any record in the event table, How do I save data? Here is my code:

  public function createAction () {$ calendar_id = (int) $ this- & gt; Params () - & gt; Fromoutout ('id', 0); If ($ calendar_id == 0) {return $ this-> Redirect () - & gt; To to route ('calendar', array ('action' => 'index')); } // echo $ calendar_id; $ Dm = $ this- & gt; GetServiceLocator () - & gt; Obtain ('doctrine.documentmanager.odm_default'); $ Form = new eventform (); $ Update = false; $ Message = ''; $ Form & gt; ('CALENDAR_ID') - & gt; setValue ($ id); $ Form & gt; Mill ('Presented') - & gt; setValue ('Add'); If ($ this-> getRequest () -> isPost ()) {$ post = $ this- & gt; getRequest () - & gt; GetPost (); $ Form & gt; setInputFilter ($ form> getInputFilter ()); $ Form & gt; setData ($ post); If ($ form-> isValid ()) {$ formData = $ form-> GetData (); $ s = new event (); $ S- & gt; SetProperty ('CALENDAR_ID', $ calendar_id); $ S- & gt; SetProperty ('title', $ post ['title']); $ S- & gt; SetProperty ('description', $ post ['description']); $ S- & gt; SetProperty ('StartDate', $ post ['start']); $ S- & gt; SetProperty ('ENDDATE', $ post ['end']); $ Dm-> Continues ($ s); $ Dm-> Flush (); $ Update = 1; $ Message = 'Calendar successfully added.'; // $ form = new calendar form (); // $ this- & gt; Redirect () - & gt; ToRoute ('Calendar'); }} Returns array ('form' = & gt; $ form, 'add_message' = & gt; $ message, 'updates' => $ update, 'calendar' = & gt; $ this- & gt; calendar) ; }    

I save the data using code set and manged m, this is my code Is:

  public function createAction () {$ dm = $ this- & gt; GetServiceLocator () - & gt; Obtain ('doctrine.documentmanager.odm_default'); $ Calendar_id = (int) $ this- & gt; Params () - & gt; Fromoutout ('id', 0); If ($ calendar_id == 0) {return $ this-> Redirect () - & gt; To to route ('calendar', array ('action' => 'index')); } $ Form = new EventForm (); $ Update = false; $ Message = ''; $ Form & gt; Ho ('CALENDAR_ID') - & gt; setValue ($ calendar_id); $ Form & gt; Mill ('Presented') - & gt; setValue ('Add'); If ($ this-> getRequest () -> isPost ()) {$ post = $ this- & gt; getRequest () - & gt; GetPost (); $ Form & gt; setInputFilter ($ form> getInputFilter ()); $ Form & gt; SetData ($ post); If ($ form-> isValid ()) {$ formData = $ form-> GetData (); $ S = new event (); $ S- & gt; SetProperty ('CALENDAR_ID', $ post ['CALENDAR_ID']); $ S- & gt; SetProperty ('title', $ post ['title']); $ S- & gt; SetProperty ('description', $ post ['description']); $ S- & gt; SetProperty ('StartDate', $ post ['start']); $ S- & gt; SetProperty ('ENDDATE', $ post ['end']); $ Dm-> Continues ($ s); $ Dm-> Flush (); $ Update = 1; $ Message = 'Calendar successfully added.'; $ form = new EventForm (); $ This- & gt; Redirect () - & gt; toRoute ('Calendar'); }} Returns array ('form' = & gt; $ form, 'add_message' = & gt; $ message, 'updates' => $ update, 'calendar' = & gt; $ this- & gt; calendar) ; }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -