cubicsquare Posted July 25, 2021 Share Posted July 25, 2021 Hi there. I managed to delete the test category (realised l had to delete the product it contained too). In the process l had already created my own first category. Test category deleted. Own first category re-added. HOWEVER: its category ID was appearing as 3, despite no other categories in existence. I deleted it. Cleared cache. Created my own first category again. HOWEVER: it appeared with an ID of 4 this time. So it keeps increasing incrementally, with CubeCart for some reason never forgetting the deletion of previous categories inasmuch as their category number lives on, forever, and ever, and ever, and ever and ever. Is there a way to directly edit category ID? I have a set menu of categories. They MUST all have the same category number, across all carts that l am setting up. Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted July 25, 2021 Share Posted July 25, 2021 The category is uses an auto increment so will always increase by one - that is Joe’s it works - standard database functionality. You could delete all categories and set the auto increment back to 0 and start again BUT creating a menu system that is dependent on fixed cat I’d numbers is a recipe for disaster Quote Link to comment Share on other sites More sharing options...
cubicsquare Posted July 25, 2021 Author Share Posted July 25, 2021 Hi there, when l delete all cats, the highest previous cat no. is not forgotten, and increment starts from there (that's the crux of my OP in fact). I know of no way to set auto increment back to 0. Please divulge. Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted July 25, 2021 Share Posted July 25, 2021 25 minutes ago, havenswift-hosting said: and set the auto increment back to 0 That is why I mentioned this Quote Link to comment Share on other sites More sharing options...
cubicsquare Posted July 25, 2021 Author Share Posted July 25, 2021 Sorry but your replies don't make sense to me. Thanks anyway. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 25, 2021 Share Posted July 25, 2021 CubeCart creates these tables to have the ID column auto-increment so that each new insertion acquires the next highest value that the table has ever had. That is, if the table once had the highest 'cat_id' value of 5, the next insertion would automatically have a 'cat_id' of 6. Yes, you can manually change the 'cat_id' values (using phpMyAdmin, for example) but each row must continue to have a unique 'cat_id' value. If, for example, 'TestCat2', when inserted into the table, acquired a 'cat_id' of 7, you can manually change that to 2 as long as there is no other row that currently has a 'cat_id' of 2. To completely start over with a fresh CubeCart_category table, issue the TRUNCATE TABLE CubeCart_category statement. (You can do this in phpMyAdmin, or using CubeCart's admin, Maintenance, Database Query tab.) Having a fresh table means the table will start the auto-increment at 1. Just to remind everyone, the 'cat_id' is the value that all other tables that deal with categories use to make their reference to: category images, sub-categories, assigned products, etc. 1 Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted July 25, 2021 Share Posted July 25, 2021 9 minutes ago, bsmither said: you can manually change that to 2 as long as there is no other row that currently has a 'cat_id' of 2. Yes you can but as you know, you then start to get into the issue of other tables that use this reference as a key. 10 minutes ago, bsmither said: issue the TRUNCATE TABLE CubeCart_category statement. (You can do this in phpMyAdmin, or using CubeCart's admin, Maintenance, Database Query tab.) Having a fresh table means the table will start the auto-increment at 1. Yes that is true but also assumes that any other table using this reference is also truncated or changed 2 hours ago, cubicsquare said: Sorry but your replies don't make sense to me. Thanks anyway. I wasnt intending to be obscure - but if you dont know what is meant by setting the table index increment back to zero, trying to explain or you trying to do can just cause far more trouble. If you dont mind learning and experimenting and can throw the whole database away if you get it wrong then by all means give it a go Quote Link to comment Share on other sites More sharing options...
cubicsquare Posted July 25, 2021 Author Share Posted July 25, 2021 Ok i've decided to leave category IDs alone and let them do their thing. Seems odd that they are even displayed if they are not really user-oriented as such. Seems that they are more to do with internal machine talk. Quote Link to comment Share on other sites More sharing options...
bsmither Posted July 25, 2021 Share Posted July 25, 2021 "Seems odd that they are even displayed" That is a weird one. Good catch! Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted July 25, 2021 Share Posted July 25, 2021 19 minutes ago, cubicsquare said: Ok i've decided to leave category IDs alone and let them do their thing. Maybe you need to look at changing the menu system so it doesnt rely on specific cat_id values Quote Link to comment Share on other sites More sharing options...
cubicsquare Posted July 26, 2021 Author Share Posted July 26, 2021 (edited) @havenswift-hosting who said it did? EDIT: OK l realise l said it did. Well, i've decided it's no longer that important to me. I just wanted dual functionality, cat id and cat name, so that l could refer to categories by either, in case l ran into a shopping cart that insisted on cat ID rather than prosaic cat name. Edited July 26, 2021 by cubicsquare Quote Link to comment 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.