CodeIgniter Forums
Pb when inserting in DB - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Pb when inserting in DB (/showthread.php?tid=27685)



Pb when inserting in DB - El Forum - 02-17-2010

[eluser]FranckRR[/eluser]
Hello guys,

controller :
Code:
....
$this->load->model('Activities');
$this->Activities->date_activity = $this->input->get_post['dateActivity'];
...
$this->Activities->insert();
$this->load->view('activitiesInserted');
....

Model:
Code:
...
var $date_activity   = '';
    function insert(){
        $this->db->insert('activities');
    }
...
What's wrong ?

Error prompted
Code:
A Database Error Occurred
Error Number: 1054

Unknown column '_ci_ob_level' in 'field list'

INSERT INTO `activities` (`id`, `date_creation`, `date_activity`, `town_id`, `activity_id`, `description`, `duree`, `paye`, `amount`, `currency_id`, `fichier_joint`, `_ci_ob_level`, `_ci_view_path`, `_ci_is_php5`, `_ci_is_instance`) VALUES ('', NULL, '2010-07-07', '17', '5', NULL, NULL, 0, NULL, NULL, NULL, 0, '/mnt/164/free.fr/0/6/fraberegis/florida2010/system/application/views/', 0, 0)



Pb when inserting in DB - El Forum - 02-17-2010

[eluser]danmontgomery[/eluser]
Quote:Unknown column '_ci_ob_level' in 'field list'

There's no column _ci_ob_level in the table activities


Pb when inserting in DB - El Forum - 02-18-2010

[eluser]FranckRR[/eluser]
I wouldn't have post here to have this kind of answer ...

Of course this column is not on my table because I didn't set it so ! The question remains why CI append this to my insert (through) db->insert()


Pb when inserting in DB - El Forum - 02-19-2010

[eluser]rogierb[/eluser]
Code:
$this->db->insert('activities');

What are you inserting?
I would have expected something like
Code:
$this->db->insert('activities', $insert_array);

If you don't provide the $insert_array CI uses $this->ar_set and I have no idea how this would get filled without setting the array or using the $this->db->set() method.


Pb when inserting in DB - El Forum - 02-19-2010

[eluser]danmontgomery[/eluser]
Quote:`_ci_ob_level`, `_ci_view_path`, `_ci_is_php5`, `_ci_is_instance`

These are private members of the controller class, and are being inserted because you're trying to insert the model object.