public function onRun($currentTick)
 {
     $cnt = count($this->getOwner()->getServer()->getOnlinePlayers());
     $result = $this->mysql->query("SELECT unix_timestamp()-max(unix_timestamp(at))as m FROM players_cnt");
     $row = $result->fetch_assoc();
     $result->close();
     $m = is_array($row) ? (int) $row["m"] : 0;
     if ($m === 0 or $m > 570) {
         $this->mysql->query("DELETE FROM players_cnt WHERE unix_timestamp()-unix_timestamp(at) > 604800");
         $this->mysql->query("INSERT INTO players_cnt (connects,joins,cnt) VALUES ({$this->connects},{$this->joins},{$cnt})");
         $this->connects = 0;
         $this->joins = 0;
         $warnings = $this->mysql->get_warnings();
         if ($warnings instanceof \mysqli_warning) {
             do {
                 echo $warnings->message;
             } while ($warnings->next());
         }
     }
 }
Beispiel #2
0
 /**
  * returns a string of the warnings from mysqli
  * @return <array> array of string listing the sql warnings
  */
 public function get_warning()
 {
     $result = $this->conn->get_warnings();
     $count = sizeof($result);
     $returning = array();
     for ($i=0; $i<$count; $i++)
     {
         $returning[$i] = "Warning $i: ".$result[$i]['errno'].
             ": ".$result[$i]['message']."\n";
     }
     return $returning;
 }