From 42857fe4e9e898c8e350da2f9acb3b252b31694a Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Tue, 18 Mar 2008 05:44:25 +0000
Subject: * Added the ability to type the partial name of a region in the start
location box and go to that region if it's there. If no close match was
found, it sends you home. This is tested on mySQL. There's untested code
on grids that are based on sqlite and MSSQL. The SQL statements *should* be
right, but your results may very. * Ex, if you want to go to Wright Plaza,
you simply need to type Wright Plaza in the start location in the client when
you log-in.
---
OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 41 +++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
(limited to 'OpenSim/Framework/Data.MySQL/MySQLGridData.cs')
diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
index 584d49c..3855d99 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs
@@ -249,6 +249,47 @@ namespace OpenSim.Framework.Data.MySQL
}
///
+ /// Returns a sim profile from it's Region name string
+ ///
+ /// The region name search query
+ /// The sim profile
+ public RegionProfileData GetProfileByString(string regionName)
+ {
+ if (regionName.Length > 2)
+ {
+ try
+ {
+ lock (database)
+ {
+ Dictionary param = new Dictionary();
+ // Add % because this is a like query.
+ param["?regionName"] = regionName + "%";
+ // Order by statement will return shorter matches first. Only returns one record or no record.
+ IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", param);
+ IDataReader reader = result.ExecuteReader();
+
+ RegionProfileData row = database.readSimRow(reader);
+ reader.Close();
+ result.Dispose();
+
+ return row;
+ }
+ }
+ catch (Exception e)
+ {
+ database.Reconnect();
+ m_log.Error(e.ToString());
+ return null;
+ }
+ }
+ else
+ {
+ m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters");
+ return null;
+ }
+ }
+
+ ///
/// Adds a new profile to the database
///
/// The profile to add
--
cgit v1.1