Quellcode durchsuchen

Merge branch 'master' of https://github.com/xormplus/xorm

xormplus vor 10 Jahren
Ursprung
Commit
a6a3da0cc2
1 geänderte Dateien mit 45 neuen und 0 gelöschten Zeilen
  1. 45 0
      README.md

+ 45 - 0
README.md

@@ -1,3 +1,48 @@
 # xorm
 
 优化xorm的查询API,并提供类似ibatis的配置文件及动态SQL功能
+
+支持类似这样的链式操作
+```go
+sql:="select id,title,createdatetime,content from article where id = ?"
+rows, err := db.Sql(sql, 2).FindAll().Json()
+
+id := db.Sql(sql, 2).FindAll().Result[0]["id"]
+title := db.Sql(sql, 2).FindAll().Result[0]["title"]
+createdatetime := db.Sql(sql, 2).FindAll().Result[0]["createdatetime"]
+content := db.Sql(sql, 2).FindAll().Result[0]["content"]
+```
+
+也支持SqlMap配置,<a href="https://github.com/xormplus/xorm/blob/master/test/sql/oracle/studygolang.xml">配置文件样例 </a>
+```xml
+<sqlMap>
+	<sql id="selectAllArticle">
+		select id,title,createdatetime,content 
+		from article where id in (?1,?2)
+	</sql>
+	<sql id="selectStudentById1">
+		select * from article where id=?id
+	</sql>
+</sqlMap>
+```
+
+```go
+paramMap := map[string]interface{}{"1": 2, "2": 5}
+rows, err := db.SqlMapClient("selectAllArticle", &paramMap).FindAllByParamMap().Xml()
+```
+同时提供动态SQL支持,使用pongo2模板引擎</br></br>
+例如配置文件名:select.example.stpl</br>
+配置<a href="https://github.com/xormplus/xorm/blob/master/test/sql/oracle/select.example.stpl">样例</a>内容如下:
+```java
+select id,userid,title,createdatetime,content 
+from article where  
+{% if count>1%}
+id=?id
+{% else%}
+userid=?userid
+{% endif %}
+```
+```go
+paramMap := map[string]interface{}{"id": 2, "userid": 3, "count": 1}
+rows, err := db.SqlTemplateClient("select.example.stpl", paramMap).FindAllByParamMap().Json()
+```