• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Null from controller to model

#1
hi , sorry for english , how can i insert null  in db passing the value from controller to model ?

Controller (ajax) : 
Code:
  function change_step()
  {

    $id_cotta              = $this->input->post('id_cotta');
   
    if ( $this->input->post('data_fine_conteggio') == 'NULL') {
   
      $data_fine_conteggio   = NULL;

    } else {

      $data_fine_conteggio   = $this->input->post('data_fine_conteggio');       
    }
   
    $numero_step_conteggio = $this->input->post('numero_step_conteggio');
    $pausa                 = $this->input->post('pausa');



    $res = $this->cotte_model->cambia_step(
                                            $id_cotta,
                                            $data_fine_conteggio,
                                            $numero_step_conteggio,
                                            $pausa

                                          );

    if($res){

      return true;
    }

   
  }

Model :


Code:
  public function cambia_step(
                                $id_cotte,
                                $data_fine_conteggio,
                                $numero_step_conteggio,
                                $pausa=NULL
                             ){

        // update record  into database


        $data = array(

                      'data_fine_conteggio' => $data_fine_conteggio,
                      'numero_step_conteggio' => $numero_step_conteggio,
                      'pausa' => $pausa
                    );

       $this->db->where('id', $id_cotte);



        if($this->db->update('cotte', $data)){

            return TRUE;

        }else{

            return FALSE;

        }


  }

But if i set NULL on ajax post the field in db don't change ...
Reply

#2
@pippuccio76,

Are you sure that your database field accepts NULL values? Are you seeing any errors? If so, what are they? Why don't you kick out the generated query to see what it looks like when a NULL value is given.
Reply

#3
(01-10-2020, 11:24 AM)php_rocs Wrote: @pippuccio76,

Are you sure that your database field accepts NULL values?  Are you seeing any errors?  If so, what are they?  Why don't you kick out the generated query to see what it looks like when a NULL value is given.

My db accept null values , i don't see any error and cannot generate the last  query because i call it with ajax  ...
Reply

#4
You can, but you will need to open up the "Network" tab, look for "XHR". And then you can see the response.
Reply

#5
(01-10-2020, 12:58 PM)jreklund Wrote: You can, but you will need to open up the "Network" tab, look for "XHR". And then you can see the response.

"The request has no response data available"  ... but other field are change only data don' change
Reply

#6
You will need to add the code for last query and exit; or die; so you can see that query in that window. If you wanted to check that.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.