Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

需求是分页
链接mysql用的 go-sql-driver/mysql
我想拿到符合条件数据的总条数,但我没找到对应的方法
请教大佬们有啥方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

rows, err := db.Query("SELECT * FROM userinfo LIMIT 0,5")
原生SQL分页就可以了,总条数就用count(*)或者count(1)加上query条件。
但,你为什么不用orm去做?
gorm: https://github.com/go-gorm/gorm
xorm: https://github.com/go-xorm/xorm


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...