Esempio n. 1
0
 /**
  * @param self[] $sessions
  * @param MysqlConnection $conn
  */
 public static function saveData($sessions, MysqlConnection $conn)
 {
     $query = "INSERT INTO players(uid,names,hash,coins,lastonline,registry,lastip,histip,ipconfig,ignoring,primaryname,rank,notag,tid,teamrank,teamjointime,lastgrind,warnpts,tmpdelta,ontime,timesince)VALUES";
     $query .= implode(",", array_fill(0, count($sessions), "(%d,%s,%s,%g,%d,%d,%s,%s,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%g,%d,%d)"));
     $query .= "ON DUPLICATE KEY UPDATE names=VALUES(names),coins=coins+VALUES(tmpdelta),lastonline=VALUES(lastonline),lastip=VALUES(lastip),histip=VALUES(histip),ipconfig=VALUES(ipconfig),ignoring=VALUES(ignoring),notag=VALUES(notag),tid=VALUES(tid),teamrank=VALUES(teamrank),teamjointime=VALUES(teamjointime),lastgrind=VALUES(lastgrind),warnpts=VALUES(warnpts),ontime=ontime+VALUES(ontime)";
     $args = [];
     foreach ($sessions as $ses) {
         $data = $ses->data;
         $args[] = (int) $data["uid"];
         $args[] = $data["names"];
         $args[] = $data["hash"];
         $args[] = $data["coins"];
         $args[] = $data["lastonline"];
         $args[] = $data["registry"];
         $args[] = $data["lastip"];
         $args[] = $data["histip"];
         $args[] = $data["ipconfig"];
         $args[] = $data["ignoring"];
         $args[] = $data["primaryname"];
         $args[] = $data["rank"];
         $args[] = $data["notag"];
         $args[] = $data["tid"];
         $args[] = $data["teamrank"];
         $args[] = $data["teamjointime"];
         $args[] = $data["lastgrind"];
         $args[] = $data["warnpts"];
         $args[] = $data["coins"] - $ses->lastCoins;
         $ses->lastCoins = $data["coins"];
         $args[] = time() - $ses->onSince;
         $args[] = $ses->onSince;
         $ses->onSince = time();
     }
     $conn->query($query, MysqlConnection::RAW, ...$args);
 }
Esempio n. 2
0
 public static function fetchById(MysqlConnection $mysql, $id)
 {
     return self::fromAssoc($mysql->query("SELECT uid,class,pts,msg,issuer,unix_timestamp(creation)AS creation,id FROM warnings_logs WHERE id={$id}", MysqlConnection::ASSOC));
 }
Esempio n. 3
0
 public function updateToMysql(MysqlConnection $con)
 {
     if ($this->updated) {
         $con->query($this->insert ? "INSERT INTO kitpvp_kits(uid,kitid,name,helmet,chestplate,leggings,boots,weapon,food,arrows)VALUES(%d,%d,%s,%d,%d,%d,%d,%d,%d,%d);" : "UPDATE kitpvp_kits SET name=%3\$s,helmet=%4\$d,chestplate=%5\$d,leggings=%6\$d,boots=%7\$d,weapon=%8\$d,food=%9\$d,arrows=%10\$d WHERE uid=%1\$d AND kitid=%2\$d;", MysqlConnection::RAW, $this->uid, $this->kitid, $this->name, $this->helmet, $this->chestplate, $this->leggings, $this->boots, $this->weapon, $this->food, $this->arrows);
         $this->insert = false;
     }
 }