CLEANUP: make the code look a bit nicer
[e-DoKo.git] / db.php
diff --git a/db.php b/db.php
index 75cd8a0e83bcdcdeb77abab0d013c66450070fa5..bae70cbc943b7273f4478bce795c0d64871bb34c 100644 (file)
--- a/db.php
+++ b/db.php
@@ -466,7 +466,7 @@ function DB_get_current_trickid($gameid)
   
   if(!$sequence || $sequence==4)
     {
-      mysql_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).")");
+      mysql_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).",NULL)");
       $trickid  = mysql_insert_id();
       $sequence = 1;
       $number++;
@@ -705,12 +705,13 @@ function DB_get_hashes_by_session($session,$user)
   return $r;
 }
 
-function DB_get_ruleset($dullen,$schweinchen)
+function DB_get_ruleset($dullen,$schweinchen,$call)
 {
   $r = array();
   
   $result = mysql_query("SELECT id FROM Rulesets WHERE".
                        " dullen=".DB_quote_smart($dullen)." AND ".
+                       " call=".DB_quote_smart($call)." AND ".
                        " schweinchen=".DB_quote_smart($schweinchen));
   if($result)
     $r    = mysql_fetch_array($result,MYSQL_NUM);
@@ -722,7 +723,8 @@ function DB_get_ruleset($dullen,$schweinchen)
       /* create new one */
       $result = mysql_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
                            DB_quote_smart($dullen).",".
-                           DB_quote_smart($schweinchen).
+                           DB_quote_smart($schweinchen).",".
+                           DB_quote_smart($call).
                            ", NULL)");
       if($result)
        return mysql_insert_id();
@@ -769,9 +771,9 @@ function DB_get_PREF($myid)
 
 function DB_get_unused_randomnumbers($userstr)
 {
-  $queryresult = mysql_query("SELECT randomnumbers,Game.id FROM Game ".
+  $queryresult = mysql_query("SELECT randomnumbers,Game.id, COUNT(*) as num FROM Game ".
                             "  LEFT JOIN Hand ON Hand.game_id=Game.id ".
-                            "                 AND  user_id not in (".$userstr.")".
+                            "                 AND user_id not in (".$userstr.")".
                             "  GROUP BY  Game.id ".
                             "  HAVING num=4");