飞哥(fizzday)

Results 17 comments of 飞哥(fizzday)

这个问题, 实际上是mysql自己的问题: ``` mysql> select * from users; +-----+---------+-----+ | uid | uname | age | +-----+---------+-----+ | 1 | gorose | 20 | | 2 | gorose2 | 19...

@tobycroft 我查了下, 这个不仅仅是mysql, 而是大部分数据库都是这个准则, 他是判定sql语法的, 语法正确就不报错, 所以搞了个影响行数 ![image](https://user-images.githubusercontent.com/16734971/88498119-dc1bca00-cff4-11ea-8c60-2af20350f8b3.png) ![image](https://user-images.githubusercontent.com/16734971/88498164-fce41f80-cff4-11ea-87d6-e3ab7a770377.png)

上下文无关的最好不复用 db 对象, 文档有说明原因和解决方法

@devig the `Data(arg interface{})` also receive raw in sql builder [https://github.com/gohouse/gorose/blob/master/builder_default.go#L172](https://github.com/gohouse/gorose/blob/master/builder_default.go#L172) just do it like this ``` DB().Table("matching_times").WhereIn("user_id", userList).Data("duration=TIME_TO_SEC(TIMEDIFF("+currentTimeString+",created_at))").Update() ```

@dulumao 比如增加哪里呢

在orm中, 其实是先解析struct, 再把解析的字段用于查询, 所以, 会造成这种结果. 而这个原生查询绑定是外挂到原生查询的, 所以, 要按照struct顺序才行, 这个是database/sql底层所决定的, 也就是需要人工手动指定的 原生查询是 ``` ... var field1 stirng var field2 int rows.scan(&field1, &field2) ... ``` 从这个原生构造中就可以看出, 程序自己是无法确定哪个字段的, 除非舍弃一定的性能, 先把rows.scan绑定到map, 然后再用map去映射, 即可解决顺序问题, 这里需要额外浪费一倍的空间和性能...

@devig query and select use different cursor, you neen seperate them

use `db.Execute()` for `insert`, `update`, `delete` use `db.Query()` for `select` ``` data, e := db.Execute("UPDATE calls SET start_time = 1611236635440 where id=?",1) data, e := db.Query("SELECT * FROM calls WHERE...

@jiclivi 这个需要手动控制, 没有做智能化控制