aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs
blob: aba9329981f7020201c43cf90f4f4323083e9a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Data;
using System.Data.Common;
using libsecondlife;
using MySql.Data.MySqlClient;

using TribalMedia.Framework.Data;

namespace OpenSim.Framework.Data
{
    public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector
    {
        public OpenSimDatabaseConnector(string connectionString) : base(connectionString)
        {
        }

        public override object ConvertToDbType(object value)
        {
            if (value is LLUUID)
            {
                return ((LLUUID) value).UUID.ToString();
            }

            return base.ConvertToDbType(value);
        }

        public override BaseDataReader CreateReader(IDataReader reader)
        {
            return new OpenSimDataReader(reader);
        }
    }


    public class MySQLDatabaseMapper : OpenSimDatabaseConnector
    {
        public MySQLDatabaseMapper(string connectionString)
            : base(connectionString)
        {
        }

        public override DbConnection GetNewConnection()
        {
            MySqlConnection connection = new MySqlConnection(m_connectionString);
            return connection;
        }

        public override string CreateParamName(string fieldName)
        {
            return "?" + fieldName;
        }
    }
}