本文整理汇总了Golang中github.com/coopernurse/gorp.SqlExecutor.SelectInt方法的典型用法代码示例。如果您正苦于以下问题:Golang SqlExecutor.SelectInt方法的具体用法?Golang SqlExecutor.SelectInt怎么用?Golang SqlExecutor.SelectInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coopernurse/gorp.SqlExecutor
的用法示例。
在下文中一共展示了SqlExecutor.SelectInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetMaxRevisionByBundleVersion
func (app *App) GetMaxRevisionByBundleVersion(txn gorp.SqlExecutor, bundleVersion string) (int, error) {
revision, err := txn.SelectInt(
"SELECT IFNULL(MAX(revision), 0) FROM bundle WHERE app_id = ? AND bundle_version = ?",
app.Id,
bundleVersion,
)
return int(revision), err
}
示例2: MoreThanTwoRequestByIp
// intercepts more than two requests to ignore list add.
func MoreThanTwoRequestByIp(db gorp.SqlExecutor, entity *models.Ignore_List) bool {
sql := SQL_COUNT_MULTIPLE_IGNOREME_REQUESTS
total, err := db.SelectInt(sql, entity.Ip)
checkErr(err, "COUNT ERROR")
return total >= 2
}
示例3: HasAuthorityForEmail
func (app *App) HasAuthorityForEmail(txn gorp.SqlExecutor, email string) (bool, error) {
count, err := txn.SelectInt("SELECT COUNT(id) FROM authority WHERE app_id = ? AND email = ?", app.Id, email)
if err != nil {
return false, err
}
if count > 0 {
return true, nil
}
return false, nil
}
示例4: IsExistAuthorityForEmail
func IsExistAuthorityForEmail(txn gorp.SqlExecutor, email string) (bool, error) {
count, err := txn.SelectInt("SELECT COUNT(id) FROM authority WHERE email = ?", email)
if err != nil {
return false, err
}
if count > 0 {
return true, nil
}
return false, nil
}
示例5: isWarnSentLimitByIpOver
func isWarnSentLimitByIpOver(warning *models.Warning, db gorp.SqlExecutor) bool {
exists, err := db.SelectInt(BuildCountWarningsSql("ip"), map[string]interface{}{
"id_contact_type": warning.Id_contact_type,
"sent": true,
"interval": 24,
"ip": warning.Ip,
})
checkErr(err, "SELECT isWarnSentLimitByIpOver ERROR")
return exists > 3
}
示例6: countWarnings
// count warnings according to the param sent(true or false) and the specific type of contact
func countWarnings(sent bool, db gorp.SqlExecutor) (string, error) {
total, err := db.SelectInt(SQL_WARNING_COUNT, map[string]interface{}{
"sent": sent,
})
checkErr(err, "COUNT SENT WARNINGS ERROR")
if err != nil {
return "", err
}
return strconv.FormatInt(total, 10), nil
}
示例7: isSameWarnSentTwiceOrMoreDifferentIp
// return true if a warn, with same message and different ip, attempts to be sent more than twice, if so respond back to interface denying the service;
func isSameWarnSentTwiceOrMoreDifferentIp(warning *models.Warning, db gorp.SqlExecutor) bool {
fmt.Println("isSameWarnSentTwiceOrMoreDifferentIp")
exists, err := db.SelectInt(BuildCountWarningsSql("same_message"), map[string]interface{}{
"sent": true,
"contact": warning.Contact,
"interval": 2,
"id_message": warning.Id_message,
"ip": warning.Ip,
})
checkErr(err, "SELECT isSameWarnSentTwiceOrMoreDifferentIp ERROR")
return exists >= 2
}
示例8: UpdateDivisionRank
func (this *ClientRegionStats) UpdateDivisionRank(ex gorp.SqlExecutor) error {
this.DivisionRank = 0
if this.DivisionId != nil {
if *this.DivisionId > 0 {
result, err := ex.SelectInt("SELECT COUNT(*) from client_region_stats WHERE division_id=? AND region=? AND ladder_points > (SELECT ladder_points FROM client_region_stats WHERE client_id=? AND region=?);", *this.DivisionId, this.Region, *this.ClientId, this.Region)
if err != nil {
log.Println(err)
return nil
}
this.DivisionRank = result + 1 //Zero indexed.
}
}
return nil
}
示例9: BundlesWithPager
func (app *App) BundlesWithPager(txn gorp.SqlExecutor, page, limit int) (Bundles, int, error) {
if page < 1 {
page = 1
}
count, err := txn.SelectInt("SELECT COUNT(*) FROM bundle WHERE app_id = ?", app.Id)
if err != nil {
return nil, 0, err
}
offset := (page - 1) * limit
if int(count) <= offset {
// 空であることが明らかなのでそのまま返す
return Bundles([]*Bundle{}), int(count), nil
}
var bundles []*Bundle
_, err = txn.Select(&bundles, "SELECT * FROM bundle WHERE app_id = ? ORDER BY id DESC LIMIT ? OFFSET ?", app.Id, limit, offset)
if err != nil {
return nil, 0, err
}
return Bundles(bundles), int(count), nil
}