Mikael Louis Mikael Louis - 1 year ago 108
PHP Question

CodeIgniter insert data from table to another table, ID duplicate

i want to make a function that will send my data from a table to another table. I made it for the first time i sent the data, but i cannot do it twice or more because the ID is duplicated so my database show an error, "Duplicate entry '1' for key 'PRIMARY'"

here is my code:


public function verify2($id)


public function inserts_model($id)
$query = $this->db->get_where('info', array('note' => 'Suspicious'));
foreach($query->result() as $row){

i use a similiar code to my manual insert data, and it works perfectly with the ID increment. However in this function it is not working.

Any help is appreciated!

Answer Source

Add all fields in select except ID, N try to insert

$this->db->select('title, content, date');
$query = $this->db->get_where('info', array('note' => 'Suspicious'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download