コード例 #1
0
ファイル: Sql.cs プロジェクト: 906507516/Oxide
        public Sql Append(Sql sql)
        {
            if (_rhs != null)
                _rhs.Append(sql);
            else
                _rhs = sql;

            return this;
        }
コード例 #2
0
ファイル: Sql.cs プロジェクト: 906507516/Oxide
        private void Build(StringBuilder sb, List<object> args, Sql lhs)
        {
            if (!String.IsNullOrEmpty(_sql))
            {
                // Add SQL to the string
                if (sb.Length > 0)
                {
                    sb.Append("\n");
                }

                var sql = ProcessParams(_sql, _args, args);

                if (Is(lhs, "WHERE ") && Is(this, "WHERE "))
                    sql = "AND " + sql.Substring(6);
                if (Is(lhs, "ORDER BY ") && Is(this, "ORDER BY "))
                    sql = ", " + sql.Substring(9);

                sb.Append(sql);
            }

            // Now do rhs
            if (_rhs != null)
                _rhs.Build(sb, args, this);
        }
コード例 #3
0
        void Loaded()
        {
            if (!permission.PermissionExists("admin"))
            {
                permission.RegisterPermission("admin", this);
            }
            LoadData();
            if (useSQLITE)
            {
                sqconnection = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").OpenDb("PlayerDatabaseSQL");
                sqlite       = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").NewSql();
                sqlite.Append("create table if not exists playerdatabase (name text, steamid text)");
                Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection);
                sqlite.Append("PRAGMA encoding = 'UTF - 8'");
                Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection);
                sqlite.Append("SELECT steamid FROM playerdatabase");

                IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection);

                foreach (Dictionary <string, object> obj in res)
                {
                    foreach (object key in obj.Values)
                    {
                        AvaibleUserID.Add(key.ToString());
                    }
                }
                sqlite.Append("SELECT * FROM playerdatabase");
                res = Interface.Oxide.GetLibrary <Ext.SQLite.Libraries.SQLite>("SQLite").Query(sqlite, sqconnection);

                foreach (Dictionary <string, object> obj in res)
                {
                    Debug.Log(obj.ToString());
                    foreach (string key in obj.Keys)
                    {
                        AvaibleKeys.Add(key.ToString());
                    }
                    break;
                }
                if (AvaibleKeys.Count == 0)
                {
                    AvaibleKeys.Add("name");
                    AvaibleKeys.Add("steamid");
                }
            }
            else if (useMysql)
            {
                connection = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").OpenDb(mysqlHost, mysqlPort, mysqlDatabase, mysqlUsername, mysqlPass);
                sql        = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").NewSql();
                sql.Append("SELECT steamid FROM `" + mysqlTable + "`");
                IEnumerable <Dictionary <string, object> > res = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);
                foreach (Dictionary <string, object> obj in res)
                {
                    foreach (object key in obj.Values)
                    {
                        AvaibleUserID.Add(key.ToString());
                    }
                }
                sql = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").NewSql();
                sql.Append("SELECT * FROM `" + mysqlTable + "`");
                res = Interface.Oxide.GetLibrary <Ext.MySql.Libraries.MySql>("MySql").Query(sql, connection);
                foreach (Dictionary <string, object> obj in res)
                {
                    foreach (string key in obj.Keys)
                    {
                        AvaibleKeys.Add(key.ToString());
                    }
                    break;
                }
                if (AvaibleKeys.Count == 0)
                {
                    AvaibleKeys.Add("name");
                    AvaibleKeys.Add("steamid");
                }
            }
        }
コード例 #4
0
ファイル: Sql.cs プロジェクト: 906507516/Oxide
 private static bool Is(Sql sql, string sqltype)
 {
     return sql != null && sql._sql != null && sql._sql.StartsWith(sqltype, StringComparison.InvariantCultureIgnoreCase);
 }
コード例 #5
0
ファイル: Sql.cs プロジェクト: 906507516/Oxide
 public SqlJoinClause(Sql sql)
 {
     _sql = sql;
 }