当前位置: 首页>>代码示例>>Golang>>正文


Golang SqlExecutor.SelectInt方法代码示例

本文整理汇总了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
}
开发者ID:kayac,项目名称:alphawing,代码行数:8,代码来源:app.go

示例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

}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:11,代码来源:ignore_list.go

示例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
}
开发者ID:kayac,项目名称:alphawing,代码行数:10,代码来源:app.go

示例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
}
开发者ID:kayac,项目名称:alphawing,代码行数:10,代码来源:authority.go

示例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
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:12,代码来源:sms.go

示例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
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:14,代码来源:dashboard.go

示例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
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:15,代码来源:warnings.go

示例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
}
开发者ID:Aaah,项目名称:erosd,代码行数:17,代码来源:client.go

示例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
}
开发者ID:kayac,项目名称:alphawing,代码行数:24,代码来源:app.go


注:本文中的github.com/coopernurse/gorp.SqlExecutor.SelectInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。