It looks like you're new here. If you want to get involved, click one of these buttons!
arrayMy new data from $_POST IS:
1 =>
object(stdClass)[41]
public 'id' => string '1' (length=1)
public 'class_id' => string '25' (length=2)
public 'section_id' => string '2' (length=1)
public 'student_id' => string '1' (length=1)
public 'date' => string '2011-11-27' (length=10)
public 'attendance' => string 'present' (length=7)
On this both data one is duplicate.
array
0 =>
array
'class_id' => string '25' (length=2)
'section_id' => string '2' (length=1)
'student_id' => int 1
'date' => string '2011-11-27 00:00:00' (length=19)
'attendance' => string 'present' (length=7)
1 =>
array
'class_id' => string '25' (length=2)
'section_id' => string '2' (length=1)
'student_id' => int 2
'date' => string '2011-11-27 00:00:00' (length=19)
'attendance' => string 'present' (length=7)
$this->db->insert_batch('table_name', $data);
Comments
1. Where is the $_POST coming from?
2. Where is $data coming from with your insert_batch statement
As an FYI, find_all_assoc will give you an array result set with the key values being the 'id' value in the example provided.
on codeigniter there is a method which inserts such data with insert_batch.
now I only need to do is the data which is on database retrieved with find_all_assoc(), should not be inserted again.
$this->my_model->save($_POST);
However, for those values that are not new and you are essentially updating, you should include the records "id" value as well.