improved docs

This commit is contained in:
Lunny Xiao 2014-05-23 15:01:41 +08:00
parent 929df107f1
commit 66e697d3b1
2 changed files with 4 additions and 0 deletions

View File

@ -732,6 +732,8 @@ type User struct {
//assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0)
Please notice that Userinfo field on User should be before Userdetail because of the order on join SQL stsatement. If the order is wrong, the same name field may be set a wrong value.
Of course, If join statment is very long, you could directly use Sql():
err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users)

View File

@ -853,6 +853,8 @@ money float64 `xorm:"Numeric"`
var users = make([]User, 0)
err := engine.Table(&Userinfo{}).Join("LEFT", "userdetail", "userinfo.detail_id = userdetail.id").Find(&users)
请注意这里的Userinfo在User中的位置必须在Userdetail的前面因为他在join语句中的顺序在userdetail前面。如果顺序不对那么对于同名的列有可能会赋值出错。
当然如果Join语句比较复杂我们也可以直接用Sql函数
err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users)