diff options
author | arun <arun@nubati.net> | 2007-01-12 08:43:28 +0000 |
---|---|---|
committer | arun <arun> | 2007-01-12 08:43:28 +0000 |
commit | 68e916d4e488f110dcdab69d7827e8b2f4129cd4 (patch) | |
tree | a88b57659a73dd76da08a260be54b5f7d94eb834 /db.php | |
parent | 22390bdc9d72fe7b32375d3be898ee0fd8137a88 (diff) | |
download | e-DoKo-68e916d4e488f110dcdab69d7827e8b2f4129cd4.tar.gz e-DoKo-68e916d4e488f110dcdab69d7827e8b2f4129cd4.tar.bz2 e-DoKo-68e916d4e488f110dcdab69d7827e8b2f4129cd4.zip |
server keeps score now, several small bugfixes
Diffstat (limited to 'db.php')
-rw-r--r-- | db.php | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -59,6 +59,17 @@ function DB_get_email_by_name($name) return ""; } +function DB_get_email_by_userid($id) +{ + $result = mysql_query("SELECT email FROM User WHERE id=".DB_quote_smart($id).""); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return ""; +} + function DB_get_email_by_hash($hash) { $result = mysql_query("SELECT User.email FROM User LEFT JOIN Hand ON Hand.user_id=User.id WHERE Hand.hash=".DB_quote_smart($hash).""); @@ -122,6 +133,19 @@ function DB_get_handid_by_hash($hash) return 0; } +function DB_get_handid_by_gameid_and_position($gameid,$pos) +{ + $result = mysql_query("SELECT id FROM Hand WHERE game_id=". + DB_quote_smart($gameid)." AND position=". + DB_quote_smart($pos)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return -1; +} + function DB_get_userid_by_hash($hash) { $result = mysql_query("SELECT user_id FROM Hand WHERE hash=".DB_quote_smart($hash)); @@ -270,14 +294,17 @@ function DB_get_hand($me) function DB_get_cards_by_trick($id) { $cards = array(); - $cards[0]=0; /* need to return index 1-4 */ - + $i = 1; + $result = mysql_query("SELECT card_id FROM Play LEFT JOIN Hand_Card ON Hand_Card.id=Play.hand_card_id ". "LEFT JOIN Hand ON Hand.id=Hand_Card.hand_id ". "WHERE trick_id=". DB_quote_smart($id)." ORDER BY position ASC"); while($r = mysql_fetch_array($result,MYSQL_NUM)) - $cards[]=$r[0]; + { + $cards[$i]=$r[0]; + $i++; + } return $cards; } |