浏览代码

add QueryRows

xormplus 7 年之前
父节点
当前提交
74ce30240f
共有 3 个文件被更改,包括 20 次插入2 次删除
  1. 18 1
      session_query.go
  2. 1 0
      session_raw.go
  3. 1 1
      xorm.go

+ 18 - 1
session_query.go

@@ -212,7 +212,24 @@ func rows2Strings(rows *core.Rows) (resultsSlice []map[string]string, err error)
 	return resultsSlice, nil
 	return resultsSlice, nil
 }
 }
 
 
-// QueryString runs a raw sql and return records as []map[string]string
+func (session *Session) QueryRows(sqlorArgs ...interface{}) (*core.Rows, error) {
+	if session.isAutoClose {
+		defer session.Close()
+	}
+
+	sqlStr, args, err := session.genQuerySQL(sqlorArgs...)
+	if err != nil {
+		return nil, err
+	}
+
+	rows, err := session.queryRows(sqlStr, args...)
+	if err != nil {
+		rows.Close()
+		return nil, err
+	}
+	return rows, nil
+}
+
 func (session *Session) QueryString(sqlorArgs ...interface{}) ([]map[string]string, error) {
 func (session *Session) QueryString(sqlorArgs ...interface{}) ([]map[string]string, error) {
 	if session.isAutoClose {
 	if session.isAutoClose {
 		defer session.Close()
 		defer session.Close()

+ 1 - 0
session_raw.go

@@ -79,6 +79,7 @@ func (session *Session) queryRows(sqlStr string, args ...interface{}) (*core.Row
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
+
 	return rows, nil
 	return rows, nil
 }
 }
 
 

+ 1 - 1
xorm.go

@@ -17,7 +17,7 @@ import (
 
 
 const (
 const (
 	// Version show the xorm's version
 	// Version show the xorm's version
-	Version string = "0.6.5.0412"
+	Version string = "0.6.6.0415"
 )
 )
 
 
 func regDrvsNDialects() bool {
 func regDrvsNDialects() bool {