CSGOWinBig
CSGOWinBig copied to clipboard
Updating prices
Hello
What is the best way to update items prices, in the database?
Ehm remove all items in database and script will take them from market :). Allthough it wont save in database.
Okay sound cool, but what kind of script are you talking about? Something you will share?
I mean the CSGOWinBig site itself already has functions which grabs the price from steam market :D. So no extra script needed.
I modified the script a bit stating that if it had to pull the price I make it update in the DB.
@Kiliso sweet maybe share it ?
$marketObj = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=$hash"), true);
$medianPrice = $marketObj['median_price'];
$lowestPrice = $marketObj['lowest_price'];
if (isset($medianPrice)) {
$price = doubleval(substr($medianPrice, 1)) * 100;
$stmt = $db->prepare("UPDATE items SET currentPrice='$price', suggestedPriceMin='0' where marketName = '$name'");
$stmt->execute();
} else {
$price = doubleval(substr($lowestPrice, 1)) * 100;
$stmt = $db->prepare("UPDATE items SET currentPrice='$price', suggestedPriceMin='0' where marketName = '$name'");
$stmt->execute();
}
Just add that to the search-items.php file.
@Kiliso Can you post the whole search-items code for reference?
He meant check-items.php i guess
@TheAnthonyNL Still not 100% sure what to change in the php though, which is my point.
https://github.com/ztizzlegaming/CSGOWinBig/blob/master/src/php/check-items.php#L128
^^
pro github tip: you can do a range for the line numbers https://github.com/ztizzlegaming/CSGOWinBig/blob/master/src/php/check-items.php#L128-L146
@andrewda i know but its not that hard to figure it out right ;).
@TheAnthonyNL ;)