T.ALKAHTIRI Posted January 18, 2009 Share Posted January 18, 2009 I have created a table with ID as auto increment field, when i issue an insert command it auto increment the ID correct, but when I issue an insert command with value in the ID (like I have the last ID no is 10) and issue an insert command with ID 50 it takes it and it saved the record with the ID 50. As far as I know the auto increment should not allow you to put any number for inserting new record, or other wise it is not an auto increment any more. Can any one please explain to me this problem. Thank you very much for help. Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/ Share on other sites More sharing options...
dropfaith Posted January 18, 2009 Share Posted January 18, 2009 i just tryed this in phpmyadmin i can add any id i want to the field i have thats auto increment without changing the table so theres no problem to explain Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739638 Share on other sites More sharing options...
T.ALKAHTIRI Posted January 18, 2009 Author Share Posted January 18, 2009 Thank you for your reply; The problem is that you can insert any number in the auto increment field, but it should not allow any number it should be read only and managed by the engine. Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739642 Share on other sites More sharing options...
Daniel0 Posted January 18, 2009 Share Posted January 18, 2009 You can't do that. Just don't give it a value for your ID field. Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739659 Share on other sites More sharing options...
T.ALKAHTIRI Posted January 18, 2009 Author Share Posted January 18, 2009 Thank you very much for your reply It is true, i have searched the mysql site and It was clear that you can assign any number in the auto increment field as far as it's not duplicated. It is strange, but it is like this. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739669 Share on other sites More sharing options...
Daniel0 Posted January 18, 2009 Share Posted January 18, 2009 It's not strange. Imagine that you have a backup dump you would like to restore. In that case you would like to retain the same primary keys (otherwise you would risk breaking relations) and you would then need to supply the ID yourself. Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739673 Share on other sites More sharing options...
T.ALKAHTIRI Posted January 18, 2009 Author Share Posted January 18, 2009 You are right, but I am used to databases like foxpro database it prevent any entry in the auto increment field it makes it read only field. Any how I appreciate your reply thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/141313-solved-auto-increment-field/#findComment-739681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.