diff --git a/examples/select_from.ooc b/examples/select_from.ooc index 848ce93..9712ba4 100644 --- a/examples/select_from.ooc +++ b/examples/select_from.ooc @@ -1,5 +1,6 @@ use sqlite3 import sqlite3/[Sqlite3, ResultCodes] +import structs/HashMap main: func { db := Sqlite3 new("asd.db") @@ -7,11 +8,10 @@ main: func { stmt toString() println() res := stmt step() while(res==Sqlite3Code row){ - stmt columnName(0) println() - stmt intColumn(0) toString() println() - stmt columnName(1) println() - stmt intColumn(1) toString() println() - + h := stmt toHashMap() + h get("asd") toInt() toString() println() + h get("zxc") toInt() toString() println() + res = stmt step() } stmt finalize() diff --git a/sqlite3/Sqlite3.ooc b/sqlite3/Sqlite3.ooc index 0da6b84..63252f8 100644 --- a/sqlite3/Sqlite3.ooc +++ b/sqlite3/Sqlite3.ooc @@ -1,4 +1,5 @@ include sqlite3 +import structs/HashMap SqliteStruct: cover from sqlite3* SqliteStmtStruct: cover from sqlite3_stmt* @@ -51,14 +52,14 @@ SqliteStmt: cover from SqliteStmtStruct { toString: extern(sqlite3_sql) func -> String toHashMap: func -> HashMap{ - res := HashMap new - n := this columnCount()+1 - for(i in 1..n){ + map := HashMap new() + n := this columnCount() + for(i in 0..n){ name := this columnName(i) val := this valueColumn(i) - res put(name, val) + map put(name, val) } - return res + return map } }