Changeset 989

Show
Ignore:
Timestamp:
06/15/08 15:38:45 (6 months ago)
Author:
bastnic
Message:

fixed #618, added 2 methods to override the jDaoRecordBase object to insert/update

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r891 r989  
    254254 
    255255    } 
    256  
     256     
     257    /** 
     258     * overload this method if you wan to do additionnal things on the dao generated by the  
     259     * jFormsBase::prepareDaoFromControls method 
     260     * @param jFormsBase $form the form 
     261     * @param jDaoRecordBase $form_daorec 
     262     */     
     263    protected function _beforeSaveCreate($form, $form_daorec) { 
     264 
     265    } 
     266     
    257267    /** 
    258268     * save data of a form in a new record 
     
    267277 
    268278        if($form->check() && $this->_checkData($form, false)){ 
    269             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     279            extract($form->prepareDaoFromControls($this->dao,null,$this->dbProfil),  
     280                EXTR_PREFIX_ALL, "form"); 
     281            $this->_beforeSaveCreate($form, $form_daorec); 
     282            $form_dao->insert($form_daorec); 
     283            $id = $form_daorec->getPk(); 
    270284            $form->saveAllFiles($this->uploadsDirectory); 
    271285            $rep->action = $this->_getAction('view'); 
     
    354368 
    355369    } 
     370     
     371    /** 
     372     * overload this method if you wan to do additionnal things on the dao generated by the  
     373     * jFormsBase::prepareDaoFromControls method 
     374     * @param jFormsBase $form the form 
     375     * @param jDaoRecordBase $form_daorec 
     376     * @param mixed $id the new id of the updated record 
     377     */     
     378    protected function _beforeSaveUpdate($form, $form_daorec, $id) { 
     379 
     380    } 
    356381 
    357382    /** 
     
    368393 
    369394        if($form->check() && $this->_checkData($form, true)){ 
    370             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     395            extract($form->prepareDaoFromControls($this->dao,$id,$this->dbProfil),  
     396                EXTR_PREFIX_ALL, "form"); 
     397            $this->_beforeSaveUpdate($form, $form_daorec, $id); 
     398            $form_dao->update($form_daorec); 
    371399            $form->saveAllFiles($this->uploadsDirectory); 
    372400            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r891 r989  
    254254 
    255255    } 
    256  
     256     
     257    /** 
     258     * overload this method if you wan to do additionnal things on the dao generated by the  
     259     * jFormsBase::prepareDaoFromControls method 
     260     * @param jFormsBase $form the form 
     261     * @param jDaoRecordBase $form_daorec 
     262     */     
     263    protected function _beforeSaveCreate($form, $form_daorec) { 
     264 
     265    } 
     266     
    257267    /** 
    258268     * save data of a form in a new record 
     
    267277 
    268278        if($form->check() && $this->_checkData($form, false)){ 
    269             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     279            extract($form->prepareDaoFromControls($this->dao,null,$this->dbProfil),  
     280                EXTR_PREFIX_ALL, "form"); 
     281            $this->_beforeSaveCreate($form, $form_daorec); 
     282            $form_dao->insert($form_daorec); 
     283            $id = $form_daorec->getPk(); 
    270284            $form->saveAllFiles($this->uploadsDirectory); 
    271285            $rep->action = $this->_getAction('view'); 
     
    354368 
    355369    } 
     370     
     371    /** 
     372     * overload this method if you wan to do additionnal things on the dao generated by the  
     373     * jFormsBase::prepareDaoFromControls method 
     374     * @param jFormsBase $form the form 
     375     * @param jDaoRecordBase $form_daorec 
     376     * @param mixed $id the new id of the updated record 
     377     */     
     378    protected function _beforeSaveUpdate($form, $form_daorec, $id) { 
     379 
     380    } 
    356381 
    357382    /** 
     
    368393 
    369394        if($form->check() && $this->_checkData($form, true)){ 
    370             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     395            extract($form->prepareDaoFromControls($this->dao,$id,$this->dbProfil),  
     396                EXTR_PREFIX_ALL, "form"); 
     397            $this->_beforeSaveUpdate($form, $form_daorec, $id); 
     398            $form_dao->update($form_daorec); 
    371399            $form->saveAllFiles($this->uploadsDirectory); 
    372400            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r891 r989  
    254254 
    255255    } 
    256  
     256     
     257    /** 
     258     * overload this method if you wan to do additionnal things on the dao generated by the  
     259     * jFormsBase::prepareDaoFromControls method 
     260     * @param jFormsBase $form the form 
     261     * @param jDaoRecordBase $form_daorec 
     262     */     
     263    protected function _beforeSaveCreate($form, $form_daorec) { 
     264 
     265    } 
     266     
    257267    /** 
    258268     * save data of a form in a new record 
     
    267277 
    268278        if($form->check() && $this->_checkData($form, false)){ 
    269             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     279            extract($form->prepareDaoFromControls($this->dao,null,$this->dbProfil),  
     280                EXTR_PREFIX_ALL, "form"); 
     281            $this->_beforeSaveCreate($form, $form_daorec); 
     282            $form_dao->insert($form_daorec); 
     283            $id = $form_daorec->getPk(); 
    270284            $form->saveAllFiles($this->uploadsDirectory); 
    271285            $rep->action = $this->_getAction('view'); 
     
    354368 
    355369    } 
     370     
     371    /** 
     372     * overload this method if you wan to do additionnal things on the dao generated by the  
     373     * jFormsBase::prepareDaoFromControls method 
     374     * @param jFormsBase $form the form 
     375     * @param jDaoRecordBase $form_daorec 
     376     * @param mixed $id the new id of the updated record 
     377     */     
     378    protected function _beforeSaveUpdate($form, $form_daorec, $id) { 
     379 
     380    } 
    356381 
    357382    /** 
     
    368393 
    369394        if($form->check() && $this->_checkData($form, true)){ 
    370             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     395            extract($form->prepareDaoFromControls($this->dao,$id,$this->dbProfil),  
     396                EXTR_PREFIX_ALL, "form"); 
     397            $this->_beforeSaveUpdate($form, $form_daorec, $id); 
     398            $form_dao->update($form_daorec); 
    371399            $form->saveAllFiles($this->uploadsDirectory); 
    372400            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r891 r989  
    254254 
    255255    } 
    256  
     256     
     257    /** 
     258     * overload this method if you wan to do additionnal things on the dao generated by the  
     259     * jFormsBase::prepareDaoFromControls method 
     260     * @param jFormsBase $form the form 
     261     * @param jDaoRecordBase $form_daorec 
     262     */     
     263    protected function _beforeSaveCreate($form, $form_daorec) { 
     264 
     265    } 
     266     
    257267    /** 
    258268     * save data of a form in a new record 
     
    267277 
    268278        if($form->check() && $this->_checkData($form, false)){ 
    269             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     279            extract($form->prepareDaoFromControls($this->dao,null,$this->dbProfil),  
     280                EXTR_PREFIX_ALL, "form"); 
     281            $this->_beforeSaveCreate($form, $form_daorec); 
     282            $form_dao->insert($form_daorec); 
     283            $id = $form_daorec->getPk(); 
    270284            $form->saveAllFiles($this->uploadsDirectory); 
    271285            $rep->action = $this->_getAction('view'); 
     
    354368 
    355369    } 
     370     
     371    /** 
     372     * overload this method if you wan to do additionnal things on the dao generated by the  
     373     * jFormsBase::prepareDaoFromControls method 
     374     * @param jFormsBase $form the form 
     375     * @param jDaoRecordBase $form_daorec 
     376     * @param mixed $id the new id of the updated record 
     377     */     
     378    protected function _beforeSaveUpdate($form, $form_daorec, $id) { 
     379 
     380    } 
    356381 
    357382    /** 
     
    368393 
    369394        if($form->check() && $this->_checkData($form, true)){ 
    370             $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
     395            extract($form->prepareDaoFromControls($this->dao,$id,$this->dbProfil),  
     396                EXTR_PREFIX_ALL, "form"); 
     397            $this->_beforeSaveUpdate($form, $form_daorec, $id); 
     398            $form_dao->update($form_daorec); 
    371399            $form->saveAllFiles($this->uploadsDirectory); 
    372400            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/CREDITS

    r987 r989  
    2828Bastien Jaillot (aka bastnic) 
    2929 - bug fix in jDaoGenerator (#282) 
    30  - little improvement in the jControllerDaoCrud API (#330, #487
     30 - little improvement in the jControllerDaoCrud API (#330, #487, #618
    3131 - fixed minor bugs 
    3232 - default template and response generated by createapp (#496, #480, #515) 
  • trunk/lib/jelix/CREDITS

    r987 r989  
    2828Bastien Jaillot (aka bastnic) 
    2929 - bug fix in jDaoGenerator (#282) 
    30  - little improvement in the jControllerDaoCrud API (#330, #487
     30 - little improvement in the jControllerDaoCrud API (#330, #487, #618
    3131 - fixed minor bugs 
    3232 - default template and response generated by createapp (#496, #480, #515) 
  • trunk/lib/jelix/CREDITS

    r987 r989  
    2828Bastien Jaillot (aka bastnic) 
    2929 - bug fix in jDaoGenerator (#282) 
    30  - little improvement in the jControllerDaoCrud API (#330, #487
     30 - little improvement in the jControllerDaoCrud API (#330, #487, #618
    3131 - fixed minor bugs 
    3232 - default template and response generated by createapp (#496, #480, #515) 
  • trunk/lib/jelix/CREDITS

    r987 r989  
    2828Bastien Jaillot (aka bastnic) 
    2929 - bug fix in jDaoGenerator (#282) 
    30  - little improvement in the jControllerDaoCrud API (#330, #487
     30 - little improvement in the jControllerDaoCrud API (#330, #487, #618
    3131 - fixed minor bugs 
    3232 - default template and response generated by createapp (#496, #480, #515) 
Download in other formats: Unified Diff Zip Archive