-
Notifications
You must be signed in to change notification settings - Fork 1
/
SqlMyUtil.cs
31 lines (29 loc) · 990 Bytes
/
SqlMyUtil.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
using System.Text;
namespace DotStd
{
/// <summary>
/// SQL features specific to MySql.
/// MySQL DAYOFWEEK() returns the week day number (1 for Sunday,2 for Monday …… 7 for Saturday )
/// </summary>
public static class SqlMyUtil
{
public const string kDateFormat = "yyyy-MM-dd"; // If we must express a date as a string for database purposes, format it like this. Try NOT to use this. use DateTime instead.
public static string GetDeleteSelectSQL(string table, string select, bool safe)
{
var sb = new StringBuilder();
if (!safe)
{
sb.Append("SET SQL_SAFE_UPDATES=0;");
}
sb.Append("DELETE FROM ");
sb.Append(table);
sb.Append(" WHERE ");
sb.Append(select);
if (!safe)
{
sb.Append(";SET SQL_SAFE_UPDATES=1;");
}
return sb.ToString();
}
}
}