当前位置: 首页>>代码示例>>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;未经允许,请勿转载。