Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating prices #76

Open
signedbydc opened this issue Nov 20, 2015 · 13 comments
Open

Updating prices #76

signedbydc opened this issue Nov 20, 2015 · 13 comments

Comments

@signedbydc
Copy link

Hello

What is the best way to update items prices, in the database?

@TheAnthonyNL
Copy link

Ehm remove all items in database and script will take them from market :). Allthough it wont save in database.

@signedbydc
Copy link
Author

Okay sound cool, but what kind of script are you talking about? Something you will share?

@TheAnthonyNL
Copy link

I mean the CSGOWinBig site itself already has functions which grabs the price from steam market :D. So no extra script needed.

@Kiliso
Copy link

Kiliso commented Nov 20, 2015

I modified the script a bit stating that if it had to pull the price I make it update in the DB.

@TheAnthonyNL
Copy link

@Kiliso sweet maybe share it ?

@Kiliso
Copy link

Kiliso commented Nov 20, 2015

        $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.

@wwcam
Copy link

wwcam commented Nov 21, 2015

@Kiliso Can you post the whole search-items code for reference?

@TheAnthonyNL
Copy link

He meant check-items.php i guess

@wwcam
Copy link

wwcam commented Nov 21, 2015

@TheAnthonyNL Still not 100% sure what to change in the php though, which is my point.

@andrewda
Copy link

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

@TheAnthonyNL
Copy link

@andrewda i know but its not that hard to figure it out right ;).

@andrewda
Copy link

@TheAnthonyNL ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants