X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fdb.php;h=e389db410d3e0f5ffc258534c1068a9d8ee59aeb;hp=28100a7b8d80b7fbec0493548db5c5738437e1c8;hb=4209593d06a237995d8cc0ba527188a15cbd0376;hpb=5edd63b115fe7712c6e220fc6a0b78dbace4f3cd diff --git a/include/db.php b/include/db.php index 28100a7..e389db4 100644 --- a/include/db.php +++ b/include/db.php @@ -59,10 +59,21 @@ function DB_test() function DB_query($query) { /* debug/optimize the database - $logfile=fopen('/tmp/DBlog.log','a+'); - fwrite($logfile,"EXPLAIN $query ;\n"); - fclose($logfile); + $time = microtime(); + $return = mysql_query($query); + $time = $time - microtime(); + + if($time > 0.05) // this way we can find only the long ones + { + $logfile=fopen('/tmp/DBlog.log','a+'); + fwrite($logfile,"EXPLAIN $query ;\n"); + fwrite($logfile,"time of above query: $time\n"); + fclose($logfile); + }; + + return $return; */ + return mysql_query($query); } @@ -256,34 +267,6 @@ function DB_get_gameid_by_hash($hash) return 0; } -function DB_cancel_game($hash) -{ - $gameid = DB_get_gameid_by_hash($hash); - - if(!$gameid) - return; - - /* get the IDs of all players */ - $result = DB_query("SELECT id FROM Hand WHERE game_id=".DB_quote_smart($gameid)); - while($r = DB_fetch_array($result)) - { - $id = $r[0]; - - $tmp = DB_query_array("SELECT id FROM Hand_Card WHERE hand_id=".DB_quote_smart($id)); - DB_query("DELETE FROM Play WHERE hand_card_id=".DB_quote_smart($tmp[0])); - - DB_query("DELETE FROM Hand_Card WHERE hand_id=".DB_quote_smart($id)); - DB_query("DELETE FROM Hand WHERE id=".DB_quote_smart($id)); - } - - /* delete game */ - DB_query("DELETE FROM User_Game_Prefs WHERE game_id=".DB_quote_smart($gameid)); - DB_query("DELETE FROM Trick WHERE game_id=".DB_quote_smart($gameid)); - DB_query("DELETE FROM Game WHERE id=".DB_quote_smart($gameid)); - - return; -} - function DB_get_hand($me) { $cards = array(); @@ -961,7 +944,7 @@ function DB_is_session_active($session) { $r = DB_query_array("SELECT COUNT(*) FROM Game ". " WHERE session=$session ". - " AND status<>'gameover' "); + " AND status IN ('pre','play') "); if($r) return $r[0]; else