public function getClanName(Clan $clan) { $query = "SELECT named FROM game.tribe WHERE id=" . $clan->getTribeId() . ';'; $this->db->setQuery($query); $this->db->query(); return $this->db->loadObject(); }
/** * Returns the id of the most valuable game.tradegoodplatonic in the mapzone * * @param Mapzone $mz * @return int */ public function exploreForTrade(Mapzone $mz) { $query = 'SELECT tg FROM tradegoodtoken WHERE mapzone=' . $mz->getId() . ' ORDER BY tradevalue ASC LIMIT 1;'; $this->db->setQuery($query); $this->db->query(); $loadObj = $this->db->loadObject(); if (isset($loadObj)) { return $loadObj->tg; } else { return null; } }
/** * @param $username * @param $password * @return null|array $results */ function doLoginRequest($username, $password) { // Check if this is in the DB or not. $query = 'select * from game.useraccount where username = "******" and password = "******"'; $this->db->setQuery($query); $loginObj = $this->db->loadObject(); if (!empty($loginObj)) { $results["logged in"] = true; $results["username"] = $loginObj->username; $results["user id"] = $loginObj->id; } else { $results["logged in"] = false; } return $results; }
public function load() { $called_class = get_called_class(); $class_name = explode('\\', get_class($this)); $table = strtolower(array_pop($class_name)); $reflectionClass = new ReflectionClass($called_class); $properties = $reflectionClass->getProperties(); $query = "SELECT * FROM " . $table . " WHERE id=" . (int) $this->getId() . ";"; $this->db->setQuery($query); $this->db->query(); $obj = $this->db->loadObject(); foreach ($properties as $node) { $property = strtolower($node->getName()); if ($property != 'db' && $property != 'id' && $property != 'status') { $this->{$property} = $obj->{$property}; } } }
/** * @param $userid * @param $named * @param $culture * @param $city * @param $allegiance * @return int */ private function newPlayerAgent($userid, $named, $culture, $city, $allegiance) { // Create an undefined object to be assembled and pass it the DB $agent = new Agent(null); $agent->setDb($this->db); // Plunk, plonk, plonk $agent->setIsplayer(true); $agent->setUserid($userid); $agent->setNamed($named); $agent->setCulture($culture); // Get the player's chosen city out of the DB $query = 'SELECT * FROM game.city WHERE named="' . $city . '";'; $this->db->setQuery($query); $this->db->query(); $dbObject = $this->db->loadObject(); // Plunk, plonk, city data $agent->setX($dbObject->x); $agent->setY($dbObject->y); $agent->setCity($dbObject->id); $agent->setActivity('idle'); // Create a new buildinglist and point the value of $this->holdings to its primary key $query = 'INSERT INTO game.estate(id) VALUES(null);'; $this->db->setQuery($query); $this->db->query(); $agent->setHoldings($this->db->getLastInsertId()); // Ditto for a blank persona $query = 'INSERT INTO game.persona(id) VALUES(null);'; $this->db->setQuery($query); $this->db->query(); $agent->setPersona($this->db->getLastInsertId()); // Plunk $agent->setAllegiance($allegiance); // Insert the new Agent into SQL and return the primary key $agent->update(); return $this->db->getLastInsertId(); }