• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ARC Delete/Insert creates additional ID

#1
[eluser]Unknown[/eluser]
I'm not sure exactly why this is happening, and I don't know if this is a bug or not. I have a simple table. Here is the create statement for it.

Code:
CREATE TABLE `brokerage_zip_range` (
     `id` int(11) NOT NULL auto_increment,
     `zip_code` varchar(10) NOT NULL,
     `brokerage_id` int(11) NOT NULL,
     PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1

I have code that looks like this in a model:

Code:
public function assign_zip_range($brokerage_id, $zip_code_list) {
     $this->db->where('brokerage_id',$brokerage_id);
     $this->db->delete('brokerage_zip_range');
        
     $this->db->set('brokerage_id', $brokerage_id);
     $this->db->set('zip_code', $zip_code_list);
     $this->db->insert('brokerage_zip_range');
}

(Please note that for reasons I won't get into here, I can't just make this an update statement).

The problem I am having is that while this code executes fine, the inserted record is incremented by more than one. So, prior to the execution of this code, the record might look like:

Code:
id    zip_code brokerage_id
7     95202     2

After I run the code (say, with zip code 92222), it now looks like:

Code:
id    zip_code brokerage_id
9     92222     2

The next auto increment value should be 8, not 9.

Am I doing something wrong or is this a CI thing? Also, I will point out that I have tried running this code by itself in CI, meaning there are no other operations happening at all before or after it.


Messages In This Thread
ARC Delete/Insert creates additional ID - by El Forum - 03-03-2011, 06:52 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.