Merge 86ce70fea2
into a4d3be797f
This commit is contained in:
commit
734fd0c240
|
@ -123,13 +123,10 @@ Or
|
||||||
|
|
||||||
Please visit [Xorm on Google Groups](https://groups.google.com/forum/#!forum/xorm)
|
Please visit [Xorm on Google Groups](https://groups.google.com/forum/#!forum/xorm)
|
||||||
|
|
||||||
# Contributors
|
# Contributing
|
||||||
|
|
||||||
If you want to pull request, please see [CONTRIBUTING](https://github.com/go-xorm/xorm/blob/master/CONTRIBUTING.md)
|
If you want to pull request, please see [CONTRIBUTING](https://github.com/go-xorm/xorm/blob/master/CONTRIBUTING.md)
|
||||||
|
|
||||||
* [Lunny](https://github.com/lunny)
|
|
||||||
* [Nashtsai](https://github.com/nashtsai)
|
|
||||||
|
|
||||||
# LICENSE
|
# LICENSE
|
||||||
|
|
||||||
BSD License
|
BSD License
|
||||||
|
|
|
@ -124,13 +124,10 @@ xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作
|
||||||
|
|
||||||
请加入QQ群:280360085 进行讨论。
|
请加入QQ群:280360085 进行讨论。
|
||||||
|
|
||||||
# 贡献者
|
## 贡献
|
||||||
|
|
||||||
如果您也想为Xorm贡献您的力量,请查看 [CONTRIBUTING](https://github.com/go-xorm/xorm/blob/master/CONTRIBUTING.md)
|
如果您也想为Xorm贡献您的力量,请查看 [CONTRIBUTING](https://github.com/go-xorm/xorm/blob/master/CONTRIBUTING.md)
|
||||||
|
|
||||||
* [Lunny](https://github.com/lunny)
|
|
||||||
* [Nashtsai](https://github.com/nashtsai)
|
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
BSD License
|
BSD License
|
||||||
|
|
|
@ -385,7 +385,7 @@ engine.Cols("age", "name").Update(&user)
|
||||||
* Omit(...string)
|
* Omit(...string)
|
||||||
和cols相反,此函数指定排除某些指定的字段。注意:此方法和Cols方法不可同时使用
|
和cols相反,此函数指定排除某些指定的字段。注意:此方法和Cols方法不可同时使用
|
||||||
```Go
|
```Go
|
||||||
engine.Cols("age").Update(&user)
|
engine.Omit("age").Update(&user)
|
||||||
// UPDATE user SET name = ? AND department = ?
|
// UPDATE user SET name = ? AND department = ?
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ xorm 快速入门
|
||||||
* [5.6.Count方法](#66)
|
* [5.6.Count方法](#66)
|
||||||
* [5.7.Rows方法](#67)
|
* [5.7.Rows方法](#67)
|
||||||
* [6.更新数据](#70)
|
* [6.更新数据](#70)
|
||||||
* [6.1.乐观锁](#71)
|
* [6.1.乐观锁](#71)
|
||||||
* [7.删除数据](#80)
|
* [7.删除数据](#80)
|
||||||
* [8.执行SQL查询](#90)
|
* [8.执行SQL查询](#90)
|
||||||
* [9.执行SQL命令](#100)
|
* [9.执行SQL命令](#100)
|
||||||
|
@ -419,7 +419,7 @@ engine.Cols("age", "name").Update(&user)
|
||||||
* Omit(...string)
|
* Omit(...string)
|
||||||
和cols相反,此函数指定排除某些指定的字段。注意:此方法和Cols方法不可同时使用
|
和cols相反,此函数指定排除某些指定的字段。注意:此方法和Cols方法不可同时使用
|
||||||
```Go
|
```Go
|
||||||
engine.Cols("age").Update(&user)
|
engine.Omit("age").Update(&user)
|
||||||
// UPDATE user SET name = ? AND department = ?
|
// UPDATE user SET name = ? AND department = ?
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -3314,7 +3314,7 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.IsCreated || col.IsUpdated) && session.Statement.UseAutoTime {
|
if (col.IsCreated || col.IsUpdated) && session.Statement.UseAutoTime {
|
||||||
args = append(args, time.Now())
|
args = append(args, session.Engine.NowTime(col.SQLType.Name))
|
||||||
} else if col.IsVersion && session.Statement.checkVersion {
|
} else if col.IsVersion && session.Statement.checkVersion {
|
||||||
args = append(args, 1)
|
args = append(args, 1)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -762,11 +762,12 @@ func (statement *Statement) genCountSql(bean interface{}) (string, []interface{}
|
||||||
statement.ConditionStr = strings.Join(colNames, " AND ")
|
statement.ConditionStr = strings.Join(colNames, " AND ")
|
||||||
statement.BeanArgs = args
|
statement.BeanArgs = args
|
||||||
// count(index fieldname) > count(0) > count(*)
|
// count(index fieldname) > count(0) > count(*)
|
||||||
var id string = "0"
|
// for compitable on kinds of database, just use *
|
||||||
|
/*var id string = "0"
|
||||||
if len(table.PrimaryKeys) == 1 {
|
if len(table.PrimaryKeys) == 1 {
|
||||||
id = statement.Engine.Quote(table.PrimaryKeys[0])
|
id = statement.Engine.Quote(statement.TableName()) + "." + statement.Engine.Quote(table.PrimaryKeys[0])
|
||||||
}
|
}*/
|
||||||
return statement.genSelectSql(fmt.Sprintf("COUNT(%v) AS %v", id, statement.Engine.Quote("total"))), append(statement.Params, statement.BeanArgs...)
|
return statement.genSelectSql(fmt.Sprintf("COUNT(*) AS %v", statement.Engine.Quote("total"))), append(statement.Params, statement.BeanArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
||||||
|
|
Loading…
Reference in New Issue