Welcome Guest, Not a member yet? Register   Sign In
Pb when inserting in DB
#1

[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)
#2

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

There's no column _ci_ob_level in the table activities
#3

[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()
#4

[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.
#5

[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.




Theme © iAndrew 2016 - Forum software by © MyBB