當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。