I am trying to check the availability of records in the table. Querying the database is correct. But i can't write the code... I saw the Extensions.
Request:Code:void OnPlayerInit(BasePlayer player) { string name = player.displayName; string steamid = player.UserIDString; var sql = Sql.Builder.Append(SelectData, steamid); Puts("sql1"); _mySql.Query(sql, _mySqlConnection, list => { Puts("bif"); foreach (var entry in list) { if (entry["steamid"] == steamid) return; Puts("sql2"); sql = Sql.Builder.Append(InsertData, name, steamid, 0, 0, 0, 0, 0, 0, 0, 0); Puts("ins"); _mySql.Insert(sql, _mySqlConnection); } }); }
I'm sorry for bad english.Code:private const string InsertData = "INSERT INTO `rank` (`name`, `steamid`, `pvpkill`, `resources`, `pvpdistans`, `kd`, `death`, `hellidestr`, `explosives`, `suicide`)" + " VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9);"; private const string SelectData = "SELECT * FROM `rank` WHERE steamid=@0";
Solved MySQL SELECT
Discussion in 'Rust Development' started by Kuhulin, Jul 27, 2016.
