| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- require_once($path["entity"] . "K_Area.php");
- require_once($path["entity"] . "Unit.php");
- /**
- * A Team.
- *
- * Represents an object from the table 'unit'.
- */
- class Team extends Entity{
- /**
- * Owner identifier.
- */
- public $uid;
- /**
- * Team identifier.
- */
- public $id;
- /**
- * Team name.
- */
- public $name;
- /**
- * Team description.
- */
- public $description;
- /**
- * List of {@see Unit}s in the team.
- */
- public $unit = [];
- /**
- * Area the team is designed for.
- */
- public $area;
- /**
- * Stage the team is designed for. It can be null.
- */
- public $stage;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * monster, populating it and it's items.
- *
- * @param SQLite3 $db Connection to the database.
- * @param int $id Monster identifier.
- * @param complete If false, query only monster and k_monster.
- */
- public function __construct($db, $id, $complete = true){
- global $path;
- parent::__construct($db);
- $s = "
- SELECT
- uid,
- id,
- name,
- description,
- area_type,
- area,
- stage,
- difficulty
- FROM team
- WHERE id = '$id';
- ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->uid = $r["uid"];
- $this->id = $r["id"];
- $this->name = $r["name"];
- $this->description = $r["description"];
- $this->area = new K_Area($this->db, $r["area"], $r["area_type"]);
- $this->stage = $r["stage"];
- if ($complete){
- $s = "
- SELECT unit
- FROM team_unit
- WHERE team = '$id';
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->unit, new Unit($this->db, $r["unit"], false));
- }
- }
- }
- }
- ?>
|