I have an error when I am going to insert to database.
I have this array:
When I print_r($students) its structure is this:
Array ( [0] => stdClass Object ( [lastname] => en [firstname] => estudianten [code] => U0009876 [id_estud] => 5 ) [1] => stdClass Object ( [lastname] => Euno [firstname] => estudiante| [code] => U00020814 [id_estud] => 6 ) )
In my model I have this code:
function insert_register_students($students) {
foreach ($students as $student) {
foreach ($student['dates'] as $key => $value) {
$data = array(
'field1' =>$student['id'],
'field2' => $key,
'field3' => '',
);
$this->db->insert('mytable', $data);
}
}
}
In the model how can I do reference that $students is a stdClass Object? The last code in the model works well for me if $students is an array but now has stdClass Object.
What is my error?
Thanks for your help.