summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2016-01-24 11:37:52 -0800
committerArun Persaud <arun@nubati.net>2016-01-24 11:37:52 -0800
commitca925a50d55b02de5ba8f953e2b61c189aafd033 (patch)
treeaeda0e1a441eadcc6b861faf9872e8c536b9bf98
parentf4f8a8f0166d617a289a77cc47fabf11d88069e9 (diff)
downloade-DoKo-ca925a50d55b02de5ba8f953e2b61c189aafd033.tar.gz
e-DoKo-ca925a50d55b02de5ba8f953e2b61c189aafd033.tar.bz2
e-DoKo-ca925a50d55b02de5ba8f953e2b61c189aafd033.zip
BUGFIX: fix reusing randomnumbers in new games
need to look at randomnumbers not gameids, otherwise we always return the same randomnumbers of the first game non-of the new players was in.
-rw-r--r--include/db.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/db.php b/include/db.php
index fa7d564..f74ab4f 100644
--- a/include/db.php
+++ b/include/db.php
@@ -912,13 +912,13 @@ function DB_get_email_pref_by_uid($uid)
function DB_get_unused_randomnumbers($userstr)
{
/* optimized version of this query using temporary tables (perhaps we should use a procedure here?).
- First we create a copy of the Game table using just the gameid and the cards.
- Then in a second round we delete all the gameids of games where our players are in.
+ First we create a copy of the Game table using just the cards.
+ Then in a second round we delete all the randomnumbers of games where our players are in.
At the end we return only the first entry in the temporary table.
*/
DB_query("DROP TEMPORARY TABLE IF EXISTS gametmp;");
- DB_query("CREATE TEMPORARY TABLE gametmp SELECT id,randomnumbers FROM Game;");
- DB_query("DELETE FROM gametmp WHERE id IN (SELECT distinct game_id FROM Hand LEFT JOIN Game ON Game.id=game_id WHERE user_id IN (".$userstr."));");
+ DB_query("CREATE TEMPORARY TABLE gametmp SELECT DISTINCT randomnumbers FROM Game;");
+ DB_query("DELETE FROM gametmp WHERE randomnumbers IN (SELECT DISTINCT randomnumbers FROM Game WHERE id IN (SELECT DISTINCT game_id FROM Hand WHERE user_id IN (".$userstr.")));");
$r = DB_query_array("SELECT randomnumbers FROM gametmp LIMIT 1;");
DB_query("DROP TEMPORARY TABLE IF EXISTS gametmp;");