-
Notifications
You must be signed in to change notification settings - Fork 17
/
Database_Compat.cs
57 lines (49 loc) · 1.78 KB
/
Database_Compat.cs
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
53
54
55
56
57
using UnityEngine;
using System.Collections;
using System.Linq;
using MySql.Data.MySqlClient;
using Mono.Data.Sqlite;
using System.Collections.Generic;
// These methods are for having backwards compatibility with sqlite
// you can delete this class if you don't have plugins that
// use database methods
public partial class Database
{
private static MySqlParameter[] ToMysqlParameters(SqliteParameter[] args)
{
return args.Select(x => new MySqlParameter(x.ParameterName, x.Value)).ToArray();
}
/// <summary>
/// Backwards compatible method.
/// Execute a statement that is not a query, it translates sqliteparameters
/// into mysqlparameters
/// </summary>
/// <param name="sql">Sql.</param>
/// <param name="args">Arguments.</param>
public static void ExecuteNonQuery(string sql, params SqliteParameter[] args)
{
ExecuteNonQueryMySql(sql, ToMysqlParameters(args));
}
/// <summary>
/// Backwards compatible method.
/// Execute a scalar query, it translates sqliteparameters
/// into mysqlparameters
/// </summary>
/// <param name="sql">Sql.</param>
/// <param name="args">Arguments.</param>
public static object ExecuteScalar(string sql, params SqliteParameter[] args)
{
return ExecuteScalarMySql(sql, ToMysqlParameters(args));
}
/// <summary>
/// Backwards compatible method.
/// Execute a query, it translates sqliteparameters
/// into mysqlparameters
/// </summary>
/// <param name="sql">Sql.</param>
/// <param name="args">Arguments.</param>
public static List<List<object>> ExecuteReader(string sql, params SqliteParameter[] args)
{
return ExecuteReaderMySql(sql, ToMysqlParameters(args));
}
}