Jump to content

adding into multiple tables


sturgeon

Recommended Posts

Hello All,

 

I am creating a shopping site, I have two tables orders and order_items. I am keeping order date and user id in orders table.

In order_items i  am keeping order_id, product_id and quantity. The problem i am facing is, when the user puchases products how will i add datas to these tables both. I mean i add order date and user id in orders table but i should add them to order_item table but how will i add the order_id in that table? If you understand and reply to me i am so glad.

 

Thank you very much and have a nice day.

Link to comment
https://forums.phpfreaks.com/topic/133926-adding-into-multiple-tables/
Share on other sites

I'm not sure. I'd guess that it will keep the data for current connection (i.e. other users' action should have no effect).

However you can always lock both tables for writing before you do inserts (remember to unlock after), or use transactions (InnoDB storage required).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.