Browse Source

added getFieldsNames

Nicolas Cannasse 14 years ago
parent
commit
90250e5c00
4 changed files with 21 additions and 0 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 15 0
      std/neko/db/Mysql.hx
  3. 1 0
      std/neko/db/ResultSet.hx
  4. 4 0
      std/neko/db/Sqlite.hx

+ 1 - 0
doc/CHANGES.txt

@@ -20,6 +20,7 @@
 	all : no longer allow inline vars as metadata values
 	all : added -exclude-package compiler switch
 	all : added -include-package compiler switch
+	neko : added getFieldsNames to neko.db.ResultSet (supported in Neko 1.8.2 mysql driver)
 
 2010-08-14: 2.06
 	neko : change serializer to be able to handle instances of basic classes from other modules

+ 15 - 0
std/neko/db/Mysql.hx

@@ -45,6 +45,7 @@ private class D {
 	public static var result_get_int = load("result_get_int",2);
 	public static var result_get_float = load("result_get_float",2);
 	public static var result_set_conv_date = load("result_set_conv_date",2);
+	public static var result_fields_names = neko.Lib.loadLazy(lib,"result_get_fields_names",1);
 
 }
 
@@ -115,6 +116,20 @@ private class MysqlResultSet implements ResultSet {
 		return D.result_get_float(__r,n);
 	}
 
+	public function getFieldsNames() : Array<String> {
+		var a = D.result_fields_names(__r);
+		untyped {
+			var i = 0;
+			var l = __dollar__asize(a);
+			while( i < l ) {
+				a[i] = new String(a[i]);
+				i += 1;
+			}
+			a = Array.new1(cast a,l);
+		}
+		return a;
+	}
+
 }
 
 private class MysqlConnection implements Connection {

+ 1 - 0
std/neko/db/ResultSet.hx

@@ -36,5 +36,6 @@ interface ResultSet {
 	function getResult( n : Int ) : String;
 	function getIntResult( n : Int ) : Int;
 	function getFloatResult( n : Int ) : Float;
+	function getFieldsNames() : Null<Array<String>>;
 
 }

+ 4 - 0
std/neko/db/Sqlite.hx

@@ -181,6 +181,10 @@ private class SqliteResultSet implements ResultSet {
 	public function getFloatResult( n : Int ) : Float {
 		return result_get_float(r,n);
 	}
+	
+	public function getFieldsNames() : Array<String> {
+		return null;
+	}
 
 	static var result_next = neko.Lib.load("sqlite","result_next",1);
 	static var result_get_length = neko.Lib.load("sqlite","result_get_length",1);