is giving the following error
Error Number: 1048
Column 'scale' can not be null
INSERT INTO
teste
(escala
,id
) VALUES (NULL, NULL)Filename: C: /xampp/htdocs/SAO/system/database/DB_driver.php
Line Number: 691
I have tried to change several things but the error continues, my model is as follows:
class questionariocreate_model extends CI_Model{
public function quest_create($quest_name){
$this->load->dbforge();
$this->db->db_select('resgate');
$field = array(
'escala' => array('type' => 'TEXT'),
'id' => array('type' => 'INT'),
);
$this->dbforge->add_field($field);
$this->dbforge->create_table($quest_name, TRUE);
//$this->dbforge->add_column($quest_name,$field);
}
public function quest_resgate($quest_name,$dados){
$this->db->db_select('resgates');
$this->db->insert($quest_name,$dados);
}
}
My controller looks like this:
public function questionario_create(){
$this -> load-> model('questionariocreate_model');
$dados['p'] = $this->input->post('questionario');
$dados['n'] = $this->input->post('n');
$dados1 = array();
$dados2 = array();
$dados3 = array();
$dados4 = array();
$this->questionariocreate_model->quest_create($dados['p']);
for ($i=0; $i<=sizeof($dados['n']); $i++) {
$dados1['escala'] = $this->input->post("escala1_$i");
$dados1['id'] = $this->input->post("id1_$i");
$dados2['escala'] = $this->input->post("escala_$i");
$dados2['id'] = $this->input->post("id_$i");
$dados3['escala'] = $this->input->post("escala_$i");
$dados3['id'] = $this->input->post("id_$i");
$dados4['escala'] = $this->input->post("escala_$i");
$dados4['id'] = $this->input->post("id_$i");
$this->questionariocreate_model->quest_resgate($dados['p'],$dados1);
$this->questionariocreate_model->quest_resgate($dados['p'],$dados2);
$this->questionariocreate_model->quest_resgate($dados['p'],$dados3);
$this->questionariocreate_model->quest_resgate($dados['p'],$dados4);
}
}
I noticed looking at the preview element that it is getting the values of the post scale_ $ i, however it is giving as null at the time of saving in the database.
And another problem I'm noticing is that it's getting all the values from my foreach, and there's a checkbox in it so I get only those selected, I do not know exactly why these issues are occurring.
Thank you all.