I have this controller and model:
class MyModel extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function insert($data_array)
{
$this->db->insert('table', $data_array);
if($this->db->affected_rows() == 1) {
return true;
}
return false;
}
}
class Panel extends CI_Controller
{
public function submitPrimer()
{
// evaluate data
$this->load->library('form_validation');
$this->load->model('MyModel', 'mymodel');
// validate, set_rules....
$data = array(
'column1' => $value1;
// .....
);
if($this->mymodel->insert($data)) {
echo "inserted";
}
}
}
Is there any kind of $this->db->show_warnings() in CI. In mysql console there is 'show warnings' command which says for example if you have datatype: float and you insert like this: insert into table (attribute_float) values(''). The proper way would be insert into table (attribute_float) values(NULL).
I also am wondering if 'insert' should go to models. I always assumed only 'select/get' data would go.