當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DbMap.SelectInt方法代碼示例

本文整理匯總了Golang中github.com/coopernurse/gorp.DbMap.SelectInt方法的典型用法代碼示例。如果您正苦於以下問題:Golang DbMap.SelectInt方法的具體用法?Golang DbMap.SelectInt怎麽用?Golang DbMap.SelectInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/coopernurse/gorp.DbMap的用法示例。


在下文中一共展示了DbMap.SelectInt方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: tagExist

func tagExist(db *gorp.DbMap, name string) bool {
	id, _ := db.SelectInt("select Id from Tag where Title = ?", name)
	if id != 0 {
		return true
	}
	return false
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:7,代碼來源:tags.go

示例2: PostUser

func PostUser(r render.Render, dbmap *gorp.DbMap, res http.ResponseWriter, u User, e binding.Errors) {
	if e != nil {
		r.JSON(http.StatusBadRequest, map[string]string{"message": e[0].Message})
		return
	}
	//check user exists yet or not?
	var count int64
	count, err := dbmap.SelectInt("SELECT count(*) FROM CUSTOMER WHERE CUS_TEL=?", u.PhoneNumber)
	if err != nil {
		glog.V(1).Infof("[DEBUG:] Search customer by tel:%v fail:%v", u.PhoneNumber, err)
		r.JSON(http.StatusConflict, map[string]string{"message": "DB ERROR"})
		return
	}

	if count > 0 {
		glog.V(1).Infof("Customer with tel:%v exists yet", u.PhoneNumber)
		r.JSON(http.StatusConflict, map[string]string{"message": "User with same Tel exists"})
		return
	}

	//insert new user info to db;
	err = dbmap.Insert(&u)
	if err != nil {
		glog.V(1).Infof("[DEBUG:] Insert customer %v fail:%v", u, err)
		r.JSON(http.StatusConflict, map[string]string{"message": "DB ERROR"})
		return
	}
	r.JSON(200, map[string]string{"message": "SUCCESS"})
}
開發者ID:renhuiyang,項目名稱:go-shoppingweb-practise,代碼行數:29,代碼來源:users.go

示例3: getNeoId

func getNeoId(dbMap *gorp.DbMap, code string) (int, error) {
	id, err := dbMap.SelectInt("SELECT id FROM neo_map WHERE code ='" + code + "'")
	if err != nil {
		fmt.Println(err)
		return 0, err
	}
	return int(id), nil
}
開發者ID:mantishK,項目名稱:trainology,代碼行數:8,代碼來源:station.go

示例4: getSlug

func getSlug(db *gorp.DbMap, title string) string {
	title = chpu.Chpu(title)
	for {
		id, _ := db.SelectInt("select Id from New where Slug = ?", title)
		if id != 0 {
			title = strinc.Inc(title)
		} else {
			break
		}
	}
	return title
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:12,代碼來源:db.go

示例5: IsVisitedPage

func IsVisitedPage(Db *gorp.DbMap, fullurl string) bool {
	fullurl = n(fullurl)
	u, _ := url.Parse(fullurl)
	visited := false

	vis, err := Db.SelectInt("select Visited from SitePage"+
		" where SiteId in (select Id from Site where Domain = ?"+
		") and Url = ?", u.Host, u.RequestURI())
	if err != nil {
		return false
	}
	if vis > 0 {
		visited = true
	}

	return visited
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:17,代碼來源:db.go

示例6: Create

func Create(db *gorp.DbMap, c ChangeLog) (ChangeLog, error) {
	c.Slug = chpu.Chpu(c.Title)
	for {
		id, _ := db.SelectInt("select Id from ChangeLog where Slug = ?", c.Slug)
		if id != 0 {
			c.Slug = strinc.Inc(c.Slug)
		} else {
			break
		}
	}
	r := rate.Rate{}

	t := time.Now().UTC()
	c.Created = t.UnixNano()
	err := db.Insert(&c)
	r.Create(db, 6, c.Id)
	return c, err
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:18,代碼來源:changelog.go

示例7: Vote

func (r Rate) Vote(Db *gorp.DbMap, v string, u int64) (Rate, error) {
	var el int64
	if r.Id == 0 {
		return Rate{}, errors.New("Rate not found")
	}
	r = r.GetRate(Db, r.ItemType, r.ItemId)
	id, err := Db.SelectInt("select RateId from Vote where RateId = ? and"+
		" UserId = ?", r.Id, u)
	if err != nil {
		return Rate{}, err
	}
	if id != 0 {
		return Rate{}, errors.New("You have already voted")
	}
	switch v {
	case "a":
		el = -1
		r.Against++
		Db.Exec("update Rate set Against = Against+1 where Id = ?", r)
		break
	case "b":
		el = 1
		r.Behind++
		Db.Exec("update Rate set Behind = Behind+1 where Id = ?", r)
		break
	default:
		return Rate{}, errors.New("Vote election undefined")
	}

	r.Rate = WilsonSum(r.Behind-r.Against, r.Against+r.Behind)

	vote := Vote{
		RateId: r.Id,

		Value:  el,
		UserId: u,
	}

	Db.Update(&r)
	Db.Insert(&vote)
	return r, nil
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:42,代碼來源:rate.go

示例8: FindArticleIdByKey

// Returns 0 if not found
func FindArticleIdByKey(dbmap *gorp.DbMap, accountId int64, key string) (id int64, err error) {
	return dbmap.SelectInt(`select id from articles where account_id = $1 and key = $2`, accountId, key)
}
開發者ID:DaleWebb,項目名稱:readraptor,代碼行數:4,代碼來源:article.go


注:本文中的github.com/coopernurse/gorp.DbMap.SelectInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。