I have a bidding system that works with a robotic giving automatic bids, and also with a button where the customer can bid.
When the client clicks the button, it calls a function that executes the following query:
$qryins = "Insert into bid_account (user_id,bidpack_buy_date,bid_count,auction_id,product_id,bid_flag,bidding_price,bidding_type,bidding_time)
values('$uid',NOW(),'1','$aid','$prid','d',$newprice,'s'," . $oldtime . ")";
The part of theft is done by a procedure in the database, with the following command:
Insert into bid_account (user_id, bidpack_buy_date, bid_count, auction_id, product_id, bid_flag, bidding_price, bidding_type, bidding_time)
SELECT prox_user_id, NOW(), '1', auctionID, productID, 'd', prox_valor, 's', auc_due_time FROM t_autolances
WHERE prox_valor NOT IN (SELECT bidding_price FROM bid_account WHERE auction_id=auctionID);
Bids are run with a watch, like those auctions of cents. The problem that is occurring is that if the client clicks on the button at the same time as the robo bid, it writes to the database with the same values.
For example, timer ta in 2s, at that time the robo goes from the bid and the client also gave. By checking the bid_account table you can see that the values have been duplicated, all with the same information.
How can I get it to write one at a time? Actually what I need is for it to write the value different only for the bidding_price column, since it has values such as: 0.25
I need it to be written this way:
robo 0.25
cliente 0.26
and not like this:
robo 0.25
cliente 0.25
I did not want to put all the code here because it is very long, so I put the most important parts.