Jump to content

Database id getting auto incremented


Recommended Posts

Hi, i have a 2 modules created myself. each has its own database, these 2 modules are for product page. they have there own tabs in product page .. when i click on the first module tab in the product page . on the right hand side it shows a text field named directory name where i enter the directory name myself and i save it. This is properly getting saved in database with id = 1 and directory name = "directory name i typed"  this is done for first module which i have created

 

for the second module. the right hand side contains the same fields , in the product page i select the second module tab .and on the right hand side. i enter the directory name as i did for the first module..this is getting saved in database with id = 2 and directory name = "directory name i typed for second module" 

 

the problem is the id value of the first module is proper i.e is "1" but for the second module when saved. this has its own database table. its getting incremented to "2"  for as i know the id value should be the same for both the modules when saved once ..but the for the second module it s getting incremented to "2"  

 

Can any one tell me what is causing this problem

 

More info: i,m using a hook to save  the data from the modules into the database .. hook is triggered when product page is updated.

Link to comment
Share on other sites

abhi,

 

Not sure what goes wrong, but wouldn't it be better to add an id_product field in both tables as a reference to where the attributes belong to, and not so much pay attention to the ID of these attributes?

 

(Agree that it bothers me that I don't know where it comes from, but) maybe this is a better way to make an association anyway.

 

 

My 2 cents,

pascal.

Link to comment
Share on other sites

Hi,  Pascal Thanks for your time. yes i know these id's doesnt give much importance . i also have  id_product feild in both the module database .my problem is how is it getting incremented i need to know the cause for this.. after some research i found out that. the hook which i,m using in both the modules are of same name. whenever i update anything in the product page the hook gets called..and in turn database save method will be called from the modules . if this is the problem.. how can i solve it.. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...