0
I have a bidding system that works with a robot giving automatic bids, and also with a button where the customer can bid.
When the client clicks on 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 robot part is made by a process 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);
The bids are executed with a clock, like those dime auctions. The problem that is occurring is that if the client clicks on the button at the same time as the robo gives the bid, it writes to the database with the same values.
For example ta chronometer in 2s, at that time the robot will give the bid and the customer also gave. By checking the bid_account table you can see that the values were duplicated, all with the same information.
How can I get him to record one at a time? In fact what I need is for him to record the different value only for the column bidding_price, because it has the values as for example: 0.25
I need it recorded that way:
robo 0.25
cliente 0.26
and not like this:
robo 0.25
cliente 0.25
I didn’t want to put all the code here because it’s too long, so I put the most important parts.
Sorry to ask, but the robot exists to inflate the bids ?
– Motta
@Motta the robot exists to reach the minimum price of a product.
– Wendler
ok, in this case I would also study a "lock table" https://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-triggers.html
– Motta
What would it be like? If you can give me some example with the same query, why am I not aware of that part.
– Wendler
I don’t know Mysql to the point of doing the syntax , just from a database concept.
– Motta