本文整理汇总了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
}
示例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"})
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}