好的,下面的代码只是意味着我使用insert select delete方法将行移动到其他表中。但关于这个问题的问题是我有2个变量我想要移动,它们是$ profittext和$ closedb,它们正在另一个php文件中定义。因此,我使用更新函数将其插入到DB表中。这2个变量的类型分别是19,2十进制和10,5十进制。输出是行的移动工作,但更新功能不起作用,没有放入任何值。有没有人知道如何解决问题??
$mysqli->query("INSERT INTO `trade_history1` (user_id, trade_id, selection, date, type, size, bidprice, offerprice, stoploss, takeprofit,dateclose,close,profitandloss)
SELECT user_id, trade_id, selection, date, type, size, bidprice, offerprice, stoploss, takeprofit, 'null','null','null'
FROM `opentrades`
WHERE `trade_id` = " . $trade_id);
$mysqli-> query("UPDATE `trade_history1` SET `dateclose` = CURRENT_TIMESTAMP,
`close` = '{$closedb}',
`profitandloss` = '{$profittext}'
WHERE `trade_id`= '$trade_id'");
$mysqli->query("DELETE FROM `opentrades` WHERE `trade_id` = '$trade_id'");
答案 0 :(得分:2)
使用它:
$mysqli->query("INSERT INTO `trade_history1` (user_id, trade_id, selection, date, type, size, bidprice, offerprice, stoploss, takeprofit,dateclose,close,profitandloss) SELECT user_id, trade_id, selection, date, type, size, bidprice, offerprice, stoploss, takeprofit, 'null','null','null'
FROM `opentrades` WHERE `trade_id` = '".$trade_id."'");
$mysqli-> query("UPDATE `trade_history1` SET `dateclose` = CURRENT_TIMESTAMP, `close` = '".$closedb."', `profitandloss` = '".$profittext."' WHERE `trade_id`= '".$trade_id."'");
$mysqli->query("DELETE FROM `opentrades` WHERE `trade_id` = '".$trade_id."'");