/// <summary> /// execute a query</summary> /// <returns> /// return a JArray which contains all objects </returns> /// <param name="query"> contains the query to execute</param> /// <param name="param"> contains the parameters needed to execute the query</param> public JArray execute(String query, object[] param) { JArray array = new JArray(); if (query != null && query.Length > 0) { stmt = SQLite3.Prepare2(this.Handle, query); if (stmt != null) { if (param != null && param.Length > 0) { for (int i = 1; i <= param.Length; i++) { bindValue(param.GetValue(i - 1), i); } } while (SQLite3.Step(stmt) == SQLite3.Result.Row) { int count = SQLite3.ColumnCount(stmt); JObject obj = new JObject(); for (int i = 0; i < count; i++) { string name = SQLite3.ColumnName(stmt, i); SQLite3.ColType colType = SQLite3.ColumnType(stmt, i); switch (colType) { case SQLite3.ColType.Blob: byte[] bytes = SQLite3.ColumnByteArray(stmt, i); obj.Add(name, bytes); break; case SQLite3.ColType.Integer: int intValue = SQLite3.ColumnInt(stmt, i); obj.Add(name, intValue); break; case SQLite3.ColType.Float: double doubleValue = SQLite3.ColumnDouble(stmt, i); obj.Add(name, doubleValue); break; case SQLite3.ColType.Text: string text = SQLite3.ColumnString(stmt, i); obj.Add(name, text); break; case SQLite3.ColType.Null: default: obj.Add(name, null); break; } } array.Add(obj); } } SQLite3.Finalize(stmt); } return(array); }
/// <summary> /// execute a query</summary> /// <returns> /// return a JArray which contains all objects </returns> /// <param name="query"> contains the query to execute</param> /// <param name="param"> contains the parameters needed to execute the query</param> public JArray execute(String query, object[] param) { JArray array = new JArray(); if (query != null && query.Length > 0) { stmt = SQLite3.Prepare2(this.Handle, query); if (stmt != null) { if (param != null && param.Length > 0) { for (int i = 1; i <= param.Length; i++) { bindValue(param.GetValue(i -1), i); } } while (SQLite3.Step(stmt) == SQLite3.Result.Row) { int count = SQLite3.ColumnCount(stmt); JObject obj = new JObject(); for (int i = 0; i < count; i++) { string name = SQLite3.ColumnName(stmt, i); SQLite3.ColType colType = SQLite3.ColumnType(stmt, i); switch (colType) { case SQLite3.ColType.Blob: byte[] bytes = SQLite3.ColumnByteArray(stmt, i); obj.Add(name, bytes); break; case SQLite3.ColType.Integer: int intValue = SQLite3.ColumnInt(stmt, i); obj.Add(name, intValue); break; case SQLite3.ColType.Float: double doubleValue = SQLite3.ColumnDouble(stmt, i); obj.Add(name, doubleValue); break; case SQLite3.ColType.Text: string text = SQLite3.ColumnString(stmt, i); obj.Add(name, text); break; case SQLite3.ColType.Null: default: obj.Add(name, null); break; } } array.Add(obj); } } SQLite3.Finalize(stmt); } return array; }