Changeset 594

Show
Ignore:
Timestamp:
09/28/07 12:39:01 (1 year ago)
Author:
laurentj
Message:

fixed bug #275: a key parameter was missing on the jFormsBase:saveToDao method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php

    r593 r594  
    189189 
    190190        if($form->check() && $this->_checkDatas($form)){ 
    191             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     191            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    192192            $form->saveAllFiles($this->uploadsDirectory); 
    193193            $rep->action = $this->_getAction('view'); 
     
    265265 
    266266        if($form->check() && $this->_checkDatas($form)){ 
    267             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     267            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    268268            $form->saveAllFiles($this->uploadsDirectory); 
    269269            $rep->action = $this->_getAction('view'); 
  • branches/1.0beta3.x/lib/jelix/controllers/jControllerDaoCrud.class.php

    r593 r594  
    189189 
    190190        if($form->check() && $this->_checkDatas($form)){ 
    191             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     191            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    192192            $form->saveAllFiles($this->uploadsDirectory); 
    193193            $rep->action = $this->_getAction('view'); 
     
    265265 
    266266        if($form->check() && $this->_checkDatas($form)){ 
    267             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     267            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    268268            $form->saveAllFiles($this->uploadsDirectory); 
    269269            $rep->action = $this->_getAction('view'); 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBase.class.php

    r593 r594  
    165165     * it call insert or update depending the value of the formId stored in the container 
    166166     * @param string $daoSelector the selector of a dao file 
     167     * @param string $key the primary key for the dao. if null, takes the form ID as primary key 
    167168     * @param string $dbProfil the jDb profil to use with the dao 
    168169     * @return mixed  the primary key of the new record in a case of inserting 
    169170     * @see jDao 
    170171     */ 
    171     public function saveToDao($daoSelector, $dbProfil=''){ 
     172    public function saveToDao($daoSelector, $key = null, $dbProfil=''){ 
    172173        $dao = jDao::create($daoSelector, $dbProfil); 
    173174        $daorec = jDao::createRecord($daoSelector, $dbProfil); 
     
    195196        } 
    196197        if($this->_container->formId){ 
    197             $daorec->setPk($this->_container->formId); 
     198            if($key === null) 
     199                $key = $this->_container->formId; 
     200            $daorec->setPk($key); 
    198201            $dao->update($daorec); 
    199202        }else{ 
     203            if($key !== null) 
     204                $daorec->setPk($key); 
    200205            // todo : what about updating the formId with the Pk. 
    201206            $dao->insert($daorec); 
  • branches/1.0beta3.x/lib/jelix/forms/jFormsBase.class.php

    r593 r594  
    165165     * it call insert or update depending the value of the formId stored in the container 
    166166     * @param string $daoSelector the selector of a dao file 
     167     * @param string $key the primary key for the dao. if null, takes the form ID as primary key 
    167168     * @param string $dbProfil the jDb profil to use with the dao 
    168169     * @return mixed  the primary key of the new record in a case of inserting 
    169170     * @see jDao 
    170171     */ 
    171     public function saveToDao($daoSelector, $dbProfil=''){ 
     172    public function saveToDao($daoSelector, $key = null, $dbProfil=''){ 
    172173        $dao = jDao::create($daoSelector, $dbProfil); 
    173174        $daorec = jDao::createRecord($daoSelector, $dbProfil); 
     
    195196        } 
    196197        if($this->_container->formId){ 
    197             $daorec->setPk($this->_container->formId); 
     198            if($key === null) 
     199                $key = $this->_container->formId; 
     200            $daorec->setPk($key); 
    198201            $dao->update($daorec); 
    199202        }else{ 
     203            if($key !== null) 
     204                $daorec->setPk($key); 
    200205            // todo : what about updating the formId with the Pk. 
    201206            $dao->insert($daorec); 
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r593 r594  
    189189 
    190190        if($form->check() && $this->_checkDatas($form)){ 
    191             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     191            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    192192            $form->saveAllFiles($this->uploadsDirectory); 
    193193            $rep->action = $this->_getAction('view'); 
     
    265265 
    266266        if($form->check() && $this->_checkDatas($form)){ 
    267             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     267            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    268268            $form->saveAllFiles($this->uploadsDirectory); 
    269269            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/controllers/jControllerDaoCrud.class.php

    r593 r594  
    189189 
    190190        if($form->check() && $this->_checkDatas($form)){ 
    191             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     191            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    192192            $form->saveAllFiles($this->uploadsDirectory); 
    193193            $rep->action = $this->_getAction('view'); 
     
    265265 
    266266        if($form->check() && $this->_checkDatas($form)){ 
    267             $id = $form->saveToDao($this->dao, $this->dbProfil); 
     267            $id = $form->saveToDao($this->dao, null, $this->dbProfil); 
    268268            $form->saveAllFiles($this->uploadsDirectory); 
    269269            $rep->action = $this->_getAction('view'); 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r593 r594  
    165165     * it call insert or update depending the value of the formId stored in the container 
    166166     * @param string $daoSelector the selector of a dao file 
     167     * @param string $key the primary key for the dao. if null, takes the form ID as primary key 
    167168     * @param string $dbProfil the jDb profil to use with the dao 
    168169     * @return mixed  the primary key of the new record in a case of inserting 
    169170     * @see jDao 
    170171     */ 
    171     public function saveToDao($daoSelector, $dbProfil=''){ 
     172    public function saveToDao($daoSelector, $key = null, $dbProfil=''){ 
    172173        $dao = jDao::create($daoSelector, $dbProfil); 
    173174        $daorec = jDao::createRecord($daoSelector, $dbProfil); 
     
    195196        } 
    196197        if($this->_container->formId){ 
    197             $daorec->setPk($this->_container->formId); 
     198            if($key === null) 
     199                $key = $this->_container->formId; 
     200            $daorec->setPk($key); 
    198201            $dao->update($daorec); 
    199202        }else{ 
     203            if($key !== null) 
     204                $daorec->setPk($key); 
    200205            // todo : what about updating the formId with the Pk. 
    201206            $dao->insert($daorec); 
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r593 r594  
    165165     * it call insert or update depending the value of the formId stored in the container 
    166166     * @param string $daoSelector the selector of a dao file 
     167     * @param string $key the primary key for the dao. if null, takes the form ID as primary key 
    167168     * @param string $dbProfil the jDb profil to use with the dao 
    168169     * @return mixed  the primary key of the new record in a case of inserting 
    169170     * @see jDao 
    170171     */ 
    171     public function saveToDao($daoSelector, $dbProfil=''){ 
     172    public function saveToDao($daoSelector, $key = null, $dbProfil=''){ 
    172173        $dao = jDao::create($daoSelector, $dbProfil); 
    173174        $daorec = jDao::createRecord($daoSelector, $dbProfil); 
     
    195196        } 
    196197        if($this->_container->formId){ 
    197             $daorec->setPk($this->_container->formId); 
     198            if($key === null) 
     199                $key = $this->_container->formId; 
     200            $daorec->setPk($key); 
    198201            $dao->update($daorec); 
    199202        }else{ 
     203            if($key !== null) 
     204                $daorec->setPk($key); 
    200205            // todo : what about updating the formId with the Pk. 
    201206            $dao->insert($daorec); 
Download in other formats: Unified Diff Zip Archive