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