Exemplo n.º 1
0
 /**
  * Get all active pets owned by a user
  *
  * @param int $id
  *
  * @return array
  */
 public function getActivePetsForUser($id)
 {
     $ret = [];
     // Pet variables
     $res_id = null;
     $owner_id = null;
     $species_id = null;
     $name = null;
     $experience = null;
     $brawn = null;
     $guts = null;
     $essence = null;
     $speed = null;
     $focus = null;
     $grit = null;
     $active = null;
     // User variables
     $username = null;
     $email_address = null;
     $description = null;
     // Species variables
     $species = null;
     $type = null;
     $stats = null;
     $this->getActivePetsForUserStatement->bind_param("i", $id);
     $this->getActivePetsForUserStatement->execute();
     $this->getActivePetsForUserStatement->bind_result($res_id, $owner_id, $species_id, $name, $experience, $brawn, $guts, $essence, $speed, $focus, $grit, $active, $username, $email_address, $description, $species, $type, $stats);
     while ($this->getActivePetsForUserStatement->fetch()) {
         $newUser = new User($username, $email_address, $description);
         $newUser->setId($owner_id);
         $newSpecies = new Species($species, $type, $stats);
         $newSpecies->setId($species_id);
         $newPet = new Pet($newUser, $newSpecies, $name);
         $newPet->setId($res_id);
         $newPet->setExperience($experience);
         $newPet->setBrawn($brawn);
         $newPet->setGuts($guts);
         $newPet->setEssence($essence);
         $newPet->setSpeed($speed);
         $newPet->setFocus($focus);
         $newPet->setGrit($grit);
         $newPet->setActive(boolval($active));
         array_push($ret, $newPet);
     }
     return $ret;
 }