Welcome Guest, Not a member yet? Register   Sign In
Model insert write in db but return false
#1

HI , i have this code :

PHP 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(0999999);

              $post['pin'] = str_pad($rand6'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->insert($post);

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


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


            if ($res AND $res2) {

              log_message('debug','$res ' $res .' $res2 ' $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['messaggi_errore'] = 'Problemi invio mail con link ';

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

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

              }


            }else {

                log_message('debug','$res ' $res .' $res2 ' $res2 );


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

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

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

            

The application don't go to the if ($res1 AND $res2) because $res2 are false ( but record are strored in db) , in the log i have :

DEBUG - 2021-01-28 21:25:36 --> $res 1 $res2 0

Why ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB