Clarent Anon
New member
Hi all
I have created a website selling footwear using php and a mysql innodb database. The basic function - user selects seize, and shoe is added to cart, user can then continue to shop or buy.
At the moment when user pays for item the quantity in mysql table is reduced.
Here is my problem
If i have 2 shoes in stock, and 5 users on site selecting shoe all 5 can select shoe and purchase, but obviusly only 2 will be happy.
This is why i changed from myisam to innodb for transactions. I have 80% understanding on transactions which is cool, but on locking i'm a little lost.
Do i lock quantity row from when item added to basket and unlock at payment recieved page, is that possible ? (lock on page 1, and unlock on page 2)
Ideally i would have liked to start transaction at basket, and rollback if user leaves site or deletes from basket, and commit if user buys. Is that possible ? (can i start a transaction on one page and depending what page user ends on commit or rollback transaction)
Hope i've made myself slightly clear.
I have created a website selling footwear using php and a mysql innodb database. The basic function - user selects seize, and shoe is added to cart, user can then continue to shop or buy.
At the moment when user pays for item the quantity in mysql table is reduced.
Here is my problem
If i have 2 shoes in stock, and 5 users on site selecting shoe all 5 can select shoe and purchase, but obviusly only 2 will be happy.
This is why i changed from myisam to innodb for transactions. I have 80% understanding on transactions which is cool, but on locking i'm a little lost.
Do i lock quantity row from when item added to basket and unlock at payment recieved page, is that possible ? (lock on page 1, and unlock on page 2)
Ideally i would have liked to start transaction at basket, and rollback if user leaves site or deletes from basket, and commit if user buys. Is that possible ? (can i start a transaction on one page and depending what page user ends on commit or rollback transaction)
Hope i've made myself slightly clear.