Beispiel #1
0
 /**
  * mark players psence on the game
  * @return int|void
  * @throws \yii\db\Exception
  */
 private function managePlayersPresence()
 {
     if ($this->isNewRecord) {
         return;
     }
     if ($player = Player::findIdentity($this->join_player)) {
         $presence = 1;
     } elseif ($player = Player::findIdentity($this->reject_player)) {
         $presence = 0;
     } else {
         return;
     }
     $sql = "INSERT INTO `game_has_player` (`game_id`, `player_id`, `presence`)\n                VALUES ('{$this->id}', '{$player->id}', '{$presence}')\n                ON DUPLICATE KEY UPDATE `presence` = '{$presence}'";
     return Yii::$app->db->createCommand($sql)->execute();
 }