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


Golang SqlExecutor.Select方法代码示例

本文整理汇总了Golang中github.com/coopernurse/gorp.SqlExecutor.Select方法的典型用法代码示例。如果您正苦于以下问题:Golang SqlExecutor.Select方法的具体用法?Golang SqlExecutor.Select怎么用?Golang SqlExecutor.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coopernurse/gorp.SqlExecutor的用法示例。


在下文中一共展示了SqlExecutor.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetApps

func GetApps(txn gorp.SqlExecutor, fileIds []string) ([]*App, error) {
	if len(fileIds) <= 0 {
		return []*App{}, nil
	}

	args := make([]interface{}, len(fileIds))
	quarks := make([]string, len(fileIds))
	for i, fileId := range fileIds {
		args[i] = fileId
		quarks[i] = "?"
	}

	var apps []*App
	_, err := txn.Select(&apps, fmt.Sprintf("SELECT * FROM app WHERE file_id in (%s) ORDER BY id DESC", strings.Join(quarks, ",")), args...)
	if err != nil {
		return nil, err
	}

	return apps, nil
}
开发者ID:kayac,项目名称:alphawing,代码行数:20,代码来源:app.go

示例2: BundlesByPlatformType

func (app *App) BundlesByPlatformType(txn gorp.SqlExecutor, platformType BundlePlatformType) ([]*Bundle, error) {
	var bundles []*Bundle
	_, err := txn.Select(&bundles, "SELECT * FROM bundle WHERE app_id = ? AND platform_type = ? ORDER BY id DESC", app.Id, platformType)
	if err != nil {
		return nil, err
	}
	return bundles, nil
}
开发者ID:kayac,项目名称:alphawing,代码行数:8,代码来源:app.go

示例3: Authorities

func (app *App) Authorities(txn gorp.SqlExecutor) ([]*Authority, error) {
	var authorities []*Authority
	_, err := txn.Select(&authorities, "SELECT * FROM authority WHERE app_id = ? ORDER BY id ASC", app.Id)
	if err != nil {
		return nil, err
	}
	return authorities, nil
}
开发者ID:kayac,项目名称:alphawing,代码行数:8,代码来源:app.go

示例4: Bundles

func (app *App) Bundles(txn gorp.SqlExecutor) ([]*Bundle, error) {
	var bundles []*Bundle
	_, err := txn.Select(&bundles, "SELECT * FROM bundle WHERE app_id = ? ORDER BY id DESC", app.Id)
	if err != nil {
		return nil, err
	}
	return bundles, nil
}
开发者ID:kayac,项目名称:alphawing,代码行数:8,代码来源:app.go

示例5: Select

func Select(s gorp.SqlExecutor, builder squirrel.SelectBuilder, src interface{}) error {
	sql, args, err := builder.ToSql()
	if err != nil {
		return err
	}
	_, err = s.Select(src, sql, args...)
	return err
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:8,代码来源:sqlutil.go

示例6: GetSubjects

func GetSubjects(enc Encoder, db gorp.SqlExecutor) (int, string) {
	var subjects []models.DefaultStruct
	_, err := db.Select(&subjects, SQL_SELECT_SUBJECTS_BY_ID)
	if err != nil {
		checkErr(err, "SELECT SUBJECTS FAILED")
		return http.StatusInternalServerError, ""
	}
	return http.StatusOK, Must(enc.Encode(subjectsToIface(subjects)...))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:9,代码来源:subjects.go

示例7: GetContact_types

func GetContact_types(enc Encoder, db gorp.SqlExecutor) (int, string) {
	var contact_types []models.DefaultStruct
	_, err := db.Select(&contact_types, SQL_CONTACT_TYPES_BY_ID)
	if err != nil {
		checkErr(err, "SELECT CONTACT TYPES FAILED")
		return http.StatusBadRequest, ""
	}
	return http.StatusOK, Must(enc.Encode(contact_typesToIface(contact_types)...))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:9,代码来源:contact_types.go

示例8: GetWarnings

func GetWarnings(enc Encoder, db gorp.SqlExecutor) (int, string) {

	var warnings []models.Warning
	_, err := db.Select(&warnings, SQL_WARNING_BYID)
	checkErr(err, "LIST ALL WARNINGS ERROR")

	if err != nil {
		return http.StatusInternalServerError, ""
	}
	return http.StatusOK, Must(enc.Encode(warningsToIface(warnings)...))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:11,代码来源:warnings.go

示例9: GetMessages

func GetMessages(enc Encoder, db gorp.SqlExecutor, parms martini.Params) (int, string) {
	var messages []models.DefaultStruct
	lang_key := parms["lang_key"]

	_, err := db.Select(&messages, SQL_MESSAGES_BY_LANG_KEY, lang_key)
	if err != nil {
		checkErr(err, "select failed")
		return http.StatusBadRequest, ""
	}

	return http.StatusOK, Must(enc.Encode(messagesToIface(messages)...))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:12,代码来源:messages.go

示例10: RefreshMessages

func (i *Invite) RefreshMessages(s *gorp.SqlExecutor) error {
	var db gorp.SqlExecutor
	if s == nil {
		db = dbmap
	} else {
		db = *s
	}
	i.Messages = []Message{}
	query := "select * from message where invite = $1 order by id asc"
	_, err := db.Select(&i.Messages, query, i.Id)
	return err
}
开发者ID:randallsquared,项目名称:gochute,代码行数:12,代码来源:profile.go

示例11: PostGet

func (device *NetworkDevice) PostGet(s gorp.SqlExecutor) error {
	device.Network = GetNetwork(map[string]interface{}{"sqlexecutor": s}, map[string]interface{}{"uuid": device.NetworkUUID})

	if _, err := s.Select(&device.Options, "select * from DeviceOption where DeviceUUID = ?", device.UUID); err != nil {
		panic(err)
	}

	if _, err := s.Select(&device.Addresses, "select * from DeviceAddress where DeviceUUID = ?", device.UUID); err != nil {
		panic(err)
	}

	return nil
}
开发者ID:virtbsd,项目名称:network,代码行数:13,代码来源:network.go

示例12: PostGet

// PostGet sets Utype and Flag information on the newly instantiated Profile.
func (p *Profile) PostGet(s gorp.SqlExecutor) error {
	var err error
	fq := "select flag.* from flag inner join profile_flag on (flag = id) where profile = $1"
	_, err = s.Select(&p.Flags, fq, p.Id)
	if err != nil {
		return err
	}

	tq := "select utype.* from utype inner join profile_utype on (utype = id) where profile = $1"
	_, err = s.Select(&p.Utypes, tq, p.Id)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:randallsquared,项目名称:gochute,代码行数:17,代码来源:profile.go

示例13: GetMessagesStats

func GetMessagesStats(enc Encoder, db gorp.SqlExecutor, user sessionauth.User) (int, string) {

	u := UserById(user.UniqueId().(int), db)

	if user.IsAuthenticated() && u.UserRole == models.ROLE_ADMIN {
		var messages []models.Messages

		_, err := db.Select(&messages, SQL_MESSAGES_ALL)
		if err != nil {
			checkErr(err, "select failed")
			return http.StatusBadRequest, ""
		}

		return http.StatusOK, Must(enc.Encode(messagesToIfaceM(messages)...))
	}

	return http.StatusUnauthorized, ""
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:18,代码来源:messages.go

示例14: RefreshAttendees

func (i *Invite) RefreshAttendees(s *gorp.SqlExecutor) error {
	var db gorp.SqlExecutor
	if s == nil {
		db = dbmap
	} else {
		db = *s
	}
	i.Attendees = []Attendee{}
	query := "select profile.*, status from profile inner join profile_invite on (profile = id) where invite = $1"
	_, err := db.Select(&i.Attendees, query, i.Id)
	if err != nil {
		return err
	}
	for j := range i.Attendees {
		err := i.Attendees[j].Profile.PostGet(dbmap) // not done in this case by gorp, sigh
		if err != nil {
			return err
		}
	}
	return err
}
开发者ID:randallsquared,项目名称:gochute,代码行数:21,代码来源:profile.go

示例15: PostGet

func (jail *Jail) PostGet(s gorp.SqlExecutor) error {
	jail.NetworkDevices = network.GetNetworkDevices(map[string]interface{}{"sqlexecutor": s}, jail)

	s.Select(&jail.Mounts, "select * from MountPoint where JailUUID = ? order by MountOrder", jail.UUID)
	s.Select(&jail.Options, "select * from JailOption where JailUUID = ?", jail.UUID)
	s.Select(&jail.Routes, "select * from Route WHERE VmUUID = ?", jail.UUID)
	if len(jail.HostName) == 0 {
		jail.HostName = jail.Name
	}

	jail.BootEnvironments = make(map[string]bool)

	jail.ZFSDatasetObj = zfs.GetDataset(jail.ZFSDataset)
	for _, rootDataset := range jail.ZFSDatasetObj.Children {
		if strings.HasPrefix(rootDataset.DatasetPath, jail.ZFSDataset+"/ROOT") {
			for _, dataset := range rootDataset.Children {
				if _, ok := dataset.Options["jailadmin:be_active"]; ok == true {
					jail.BootEnvironments[dataset.DatasetPath], _ = strconv.ParseBool(dataset.Options["jailadmin:be_active"])
				}
			}

			break
		}
	}

	return nil
}
开发者ID:virtbsd,项目名称:jail,代码行数:27,代码来源:jail.go


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