} // 扣钱成功,写task表 $sql = "insert into task (owner_id, publisher_id, type, base_price, amount, status, create_at, expire_in) values('{$_SESSION['uid']}', '{$_SESSION['uid']}', 1, '{$db_base_price}', '{$amount}', 1, now(), '{$expire_in_sec}')"; $num = $dbo->exeUpdate($sql); if (1 != $num) { // 写数据表失败,回滚金钱数据 $sql2 = "update user set realtime_money=realtime_money + {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1"; $num2 = $dbo->exeUpdate($sql2); if (1 != $num2) { $msg = "回滚金钱数据失败,这个比较糟糕。SQL:" . $sql2; debug($msg, __FILE__, __LINE__); } $msg = '数据库task表插入出错,SQL:' . $sql; debug($msg, __FILE__, __LINE__); } $last_task_id = $dbo->lastInsertId(); $text = $dbo->real_escape_string($status['text']); $screen_name = $dbo->real_escape_string($status['user']['screen_name']); $location = $dbo->real_escape_string($status['user']['location']); $description = $dbo->real_escape_string($status['user']['description']); $sql = "insert into task_info_sina_repost values(NULL, '{$last_task_id}', '{$_SESSION['sid']}', '{$wid}', '{$text}', '{$screen_name}', '{$location}', '{$description}', '{$status['user']['profile_image_url']}', '{$status['thumbnail_pic_url']}', '{$status['bmiddle_pic_url']}', '{$status['original_pic_url']}')"; $num = $dbo->exeUpdate($sql); if (1 != $num) { $msg = '数据库插入数据出错。SQL:' . $sql; debug($msg, __FILE__, __LINE__); // 回滚金钱数据和task表数据 $sql1 = "delete from task where task_id = '{$last_task_id}' limit 1"; $num1 = $dbo->exeUpdate($sql1); $sql2 = "update user set realtime_money = realtime_money + {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1"; $num2 = $dbo->exeUpdate($sql2); if (1 != $num1) {