For example, a user create a product, and assign it into a category.
In the category, we have some record:
-phone, id:0
-computer, id:1
-pad, id:2
and a user create a product, the product need to assign a category, and a user do something like this:
name:iphone
cat:0
And the flow will work like this:
1. check the cat is exist in db or not
2a. if not exist prompt error
2b. if exist, put the record in db.
But is there any chance when finished the step 1 checking, and before the 2b is start. The admin delete the phone category. If this happen, the database will insert a record which have no cat id watch. The db will have something like this:
*-phone, id:0* (not any more, because the admin delete it)
-computer, id:1
-pad, id:2
But there is a record like this:
name:iphone //but it belong to no category, because the admin delete it.
cat:0
If there is a chance for doing this, how can I avoid this? Thank you.
(Using php and mysql with codeigniter)
There are two things you should think about: