/** * Create an object or return existing one. * * <code> * $locationId = 1; * * $location = SocialCommunity\Location::getInstance(\JFactory::getDbo(), $locationId); * </code> * * @param \JDatabaseDriver $db * @param array $keys * * @return null|Location */ public static function getInstance(\JDatabaseDriver $db, $keys) { $id = !isset($keys["id"]) ? 0 : (int) $keys["id"]; if (!isset(self::$instances[$id])) { $item = new Location($db); $item->load($keys); self::$instances[$id] = $item; } return self::$instances[$id]; }
/** * Create a location object and return it. * * <code> * $options = array( * "ids" => array(1,2,3,4,5) * ); * * $locations = new SocialCommunity\Locations(JFactory::getDbo()); * $locations->load($options); * * $location = $locations->getLocation(1); * </code> * * @param string $id * * @return null|Location */ public function getLocation($id) { $location = null; if (isset($this->items[$id])) { $location = new Location($this->db); $location->bind($this->items[$id]); } return $location; }