Welcome Guest, Not a member yet? Register   Sign In
Update instead insert
#1

(This post was last modified: 01-28-2021, 01:34 PM by pippuccio76.)

HI i have two model : 

User : 
protected $allowedFields = ['id','email','password','user_activation_hash','id_stato_users','pin','tipo_utente','refertatore','sconto','updated_at','last_login'];

protected $allowedFields = ['id_user','nome','cognome','data_nascita','telefono','nome_studio','numero_iscrizione_ordine','anno_iscrizione_ordine','piva','id_comuni','indirizzo','civico','cap','pec','sdi','note','normativa_ministero_salute','termini','privacy','comunicazioni'];


this is a part of controller's method :

Code:
if($this->validate($rules)){

              $post = $this->request->getPost();

              // generate random hash for email verification (40 char string)
              $user_activation_hash = sha1(uniqid(mt_rand(), true));

              $post['user_activation_hash'] = $user_activation_hash;

              //setto lo stato come 1 (da cliccare sul link)
              $post['id_stato_users'] = 1;

              //setto tipo utente come dentista(1)
              $post['tipo_utente'] = 1;

              $rand = rand(0, 999999);

              $post['pin'] = str_pad($rand, 6, '0', STR_PAD_LEFT);

              $res=$user_model->save($post);

              $post['id_user']=$user_model->insertID;

              log_message('debug',"post_id_user " . $post['id_user']);

              $res2=$dentistiModel->save($post);

              log_message('debug','dentistiModel last query ' . $dentistiModel->getLastQuery() );


              //DEBUG
              //$last_query = $model->getLastQuery();


            if ($res AND $res2) {


              if($this->send_user_activation_hash_by_email($post['email'],$post['pin'],$user_activation_hash))
              {

                $data['messaggi_ok'] = 'Registrazione andata a buon fine conferma il tuo indirizzo email cliccando sul link che ti abbiamo inviato';

                $data ['redirect'] =base_url().'/user/login';

                echo view('common/messaggi_ok',$data );

              }else{

                 $data['messaggio_errore'] = 'Problemi invio mail con link ';

                 $data ['redirect'] =base_url().'/user/login';

                 echo view('common/messaggi_errore',$data );

              }


            }else {

                 $data['messaggio_errore'] = 'Problemi registrazione dentista';

                 $data ['redirect'] =base_url().'/user/login';

                 echo view('common/messaggi_errore',$data );

            }

this is the log :
Code:
INFO - 2021-01-28 19:26:52 --> CSRF cookie sent
INFO - 2021-01-28 19:26:52 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2021-01-28 19:27:30 --> CSRF cookie sent
INFO - 2021-01-28 19:27:30 --> CSRF token verified
INFO - 2021-01-28 19:27:30 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
DEBUG - 2021-01-28 19:27:30 --> post_id_user 25
DEBUG - 2021-01-28 19:27:30 --> dentistiModel last query UPDATE `dentisti` SET `nome` = 'Stefano', `cognome` = 'Banchelli', `numero_iscrizione_ordine` = '212212', `anno_iscrizione_ordine` = '2025', `note` = '64656465', `normativa_ministero_salute` = '1', `termini` = '1', `privacy` = '1', `comunicazioni` = '1', `id_user` = 25
WHERE `dentisti`.`id_user` IN (25)
INFO - 2021-01-28 19:27:34 --> Session: Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver.
INFO - 2021-01-28 19:27:34 --> CSRF cookie sent

why don't  insert but update ?
Reply


Messages In This Thread
Update instead insert - by pippuccio76 - 01-28-2021, 12:51 PM
RE: Update instead insert - by neoneeco - 01-28-2021, 01:32 PM
RE: Update instead insert - by pippuccio76 - 01-28-2021, 01:34 PM
RE: Update instead insert - by InsiteFX - 01-28-2021, 09:53 PM
RE: Update instead insert - by pippuccio76 - 01-28-2021, 11:07 PM
RE: Update instead insert - by demyr - 01-29-2021, 04:50 AM
RE: Update instead insert - by pippuccio76 - 01-29-2021, 05:05 AM
RE: Update instead insert - by demyr - 01-29-2021, 05:19 AM
RE: Update instead insert - by pippuccio76 - 01-29-2021, 11:18 AM
RE: Update instead insert - by demyr - 01-29-2021, 12:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB