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


Golang Tx.Get方法代碼示例

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


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

示例1: GetOwnerInfos

// GetOwnerInfos get all informations about the owner of the database
func (d *Database) GetOwnerInfos(tx *sqlx.Tx) (owner DatabaseAuthor, err error) {
	err = tx.Get(owner, "SELECT * FROM \"user\" u LEFT JOIN \"database\" d ON u.id = d.owner WHERE d.id = $1", d.Id)
	if err != nil {
		err = errors.New("database::GetOwnerInfos: " + err.Error())
	}
	return
}
開發者ID:croll,項目名稱:arkeogis-server,代碼行數:8,代碼來源:database.go

示例2: get

func (b *Base) get(tx *sqlx.Tx, dest interface{}, query string, args ...interface{}) error {
	if tx != nil {
		return tx.Get(dest, query, args...)
	}

	return b.db.Get(dest, query, args...)
}
開發者ID:BrianHarringtonUTSC,項目名稱:uTeach,代碼行數:7,代碼來源:base.go

示例3: getDBMediaPlayerTx

func getDBMediaPlayerTx(tx *sqlx.Tx, id int64, baseComp Component, exFlags ExpansionFlags) (dbMediaPlayer, error) {
	var dbMP dbMediaPlayer

	// build a select statement based on the expand keys
	stmt := "SELECT * FROM component c JOIN media_player_state mpstate ON c.id=mpstate.id"

	if exFlags&(ExpandAll|ExpandSpecs) != 0 {
		stmt += " JOIN media_player_spec mpspec ON mpspec.make=c.make AND mpspec.model=c.model"
	}

	// TODO: Add stats
	//	if exFlags&(ExpandAll|exFlags&ExpandStats) != 0 {
	//		stmt += " JOIN media_player_stats lstats ON c.id=lstats.id"
	//	}
	stmt += " WHERE c.id=? LIMIT 1"
	Log.Debug("getting media player", "query", stmt, "id", id)
	if err := tx.Get(&dbMP, stmt, id); err != nil {
		return dbMediaPlayer{}, fmt.Errorf("error getting media player with id %v: %v", id, err)
	}

	if dbMP.ID == 0 {
		Log.Warn("media player has id 0", "search_id", id)
		return dbMediaPlayer{}, fmt.Errorf("got unexpected component id: 0")
	}
	return dbMP, nil
}
開發者ID:upwrd,項目名稱:sift,代碼行數:26,代碼來源:db.go

示例4: CreateIdentity

func CreateIdentity(tx *sqlx.Tx, identity *Identity) error {
	const (
		Q = `INSERT INTO identities DEFAULT VALUES RETURNING *;`
	)

	return tx.Get(identity, Q)
}
開發者ID:rogeriomarques,項目名稱:oapx,代碼行數:7,代碼來源:identity.go

示例5: GetLastImport

// GetLastImport lists last import informations
func (d *Database) GetLastImport(tx *sqlx.Tx) (imp Import, err error) {
	imp = Import{}
	err = tx.Get(&imp, "SELECT * FROM import WHERE i.jdatabase_id = $1 ORDER by id DESC LIMIT 1", d.Id)
	if err != nil {
		err = errors.New("database::GetLastImport: " + err.Error())
	}
	return
}
開發者ID:croll,項目名稱:arkeogis-server,代碼行數:9,代碼來源:database.go

示例6: GetProjectId

// GetProjectId get the project of the user
func (u *User) GetProjectId(tx *sqlx.Tx) (projectID int, err error) {
	err = tx.Get(&projectID, "SELECT id FROM project WHERE user_id = $1", u.Id)
	if err == sql.ErrNoRows {
		err = nil
		projectID = 0
	}
	return
}
開發者ID:croll,項目名稱:arkeogis-server,代碼行數:9,代碼來源:user.go

示例7: getBaseComponentTx

func getBaseComponentTx(tx *sqlx.Tx, deviceID types.DeviceID, compName string) (Component, bool) {
	var dbComp Component
	err := tx.Get(&dbComp, "SELECT * FROM component WHERE device_id=? AND name=? LIMIT 1", deviceID, compName)
	if err != nil || dbComp.ID == 0 {
		return dbComp, false
	}
	return dbComp, true
}
開發者ID:upwrd,項目名稱:sift,代碼行數:8,代碼來源:db.go

示例8: GetBuildIDFromDBTx

// GetBuildIDFromDBTx retrieves the ID for the given build from the database
// as specified by the given master, builder, and build number.
func GetBuildIDFromDBTx(builder, master string, buildNumber int, tx *sqlx.Tx) (int, error) {
	var id int
	stmt := fmt.Sprintf("SELECT id FROM %s WHERE builder = ? AND master = ? AND number = ?", TABLE_BUILDS)
	if err := tx.Get(&id, stmt, builder, master, buildNumber); err != nil {
		return -1, fmt.Errorf("Unable to retrieve build ID from database: %v", err)
	}
	return id, nil
}
開發者ID:1394,項目名稱:skia-buildbot,代碼行數:10,代碼來源:db.go

示例9: getDBDeviceTx

func getDBDeviceTx(tx *sqlx.Tx, extID types.ExternalDeviceID) (Device, bool) {
	var dev Device
	err := tx.Get(&dev, "SELECT * FROM device WHERE manufacturer=? AND external_id=? LIMIT 1", extID.Manufacturer, extID.ID)
	if err != nil || dev.ID == 0 {
		Log.Debug("could not get dbDevice", "err", err, "ext_id", extID, "dbDev_id", dev.ID)
		return dev, false
	}
	return dev, true
}
開發者ID:upwrd,項目名稱:sift,代碼行數:9,代碼來源:db.go

示例10: IsLinkedToProject

// IsLinkedToProject returns true or false if database is linked or not to user project
func (d *Database) IsLinkedToProject(tx *sqlx.Tx, project_ID int) (linked bool, err error) {
	linked = false
	c := 0
	err = tx.Get(&c, "SELECT count(*) FROM project__database WHERE project_id = $1 AND database_id = $2", project_ID, d.Id)
	if c > 0 {
		linked = true
	}
	return
}
開發者ID:croll,項目名稱:arkeogis-server,代碼行數:10,代碼來源:database.go

示例11: artifactsFindByRepoSha

// artifactsFindByRepoSha finds an artifact by image.
func artifactsFindByRepoSha(tx *sqlx.Tx, repoSha string) (*Artifact, error) {
	parts := strings.Split(repoSha, "@")
	var sql = `SELECT * FROM artifacts
WHERE repository = ?
AND sha = ?
ORDER BY seq desc
LIMIT 1`
	var a Artifact
	err := tx.Get(&a, tx.Rebind(sql), parts[0], parts[1])
	return &a, err
}
開發者ID:atmos,項目名稱:conveyor,代碼行數:12,代碼來源:artifacts.go

示例12: findConsumer

func findConsumer(id int, db *sqlx.Tx) *Consumer {
	consumer := &Consumer{}
	consumer._db = db

	db.Get(consumer, "SELECT `id`, `name`, `created_at`, `updated_at`, `created_by`, `updated_by`, `enabled`, `deleted`, `info_token` FROM `consumer` WHERE `id` = ?", id)
	if consumer.Id == 0 {
		return nil
	}

	return consumer
}
開發者ID:xrstf,項目名稱:raziel,代碼行數:11,代碼來源:consumer.go

示例13: buildsFindByRepoSha

// buildsFindByRepoSha finds a build by repository and sha.
func buildsFindByRepoSha(tx *sqlx.Tx, repoSha string) (*Build, error) {
	parts := strings.Split(repoSha, "@")
	var sql = `SELECT * FROM builds
WHERE repository = ?
AND sha = ?
ORDER BY seq desc
LIMIT 1`
	var b Build
	err := tx.Get(&b, tx.Rebind(sql), parts[0], parts[1])
	return &b, err
}
開發者ID:atmos,項目名稱:conveyor,代碼行數:12,代碼來源:builds.go

示例14: GetLastHandle

// GetHandles get last handle linked to a database
func (d *Database) GetLastHandle(tx *sqlx.Tx) (handle *Database_handle, err error) {
	handle = &Database_handle{}
	err = tx.Get(handle, "SELECT * FROM database_handle WHERE database_id = $1 ORDER BY id DESC LIMIT 1", d.Id)
	switch {
	case err == sql.ErrNoRows:
		return handle, nil
	case err != nil:
		return
	}
	return
}
開發者ID:croll,項目名稱:arkeogis-server,代碼行數:12,代碼來源:database.go

示例15: getBaseComponentByIDTx

func getBaseComponentByIDTx(tx *sqlx.Tx, id int64) (Component, error) {
	var dbComp Component
	if err := tx.Get(&dbComp, "SELECT * FROM component WHERE id=? LIMIT 1", id); err != nil {
		Log.Debug("could not get base component", "id", id, "err", err)
		return Component{}, fmt.Errorf("error getting component with id %v: %v", id, err)
	}
	if dbComp.ID == 0 {
		Log.Warn("base component has id 0", "search_id", id)
		return Component{}, fmt.Errorf("got unexpected component id: 0")
	}
	Log.Debug("got base component", "id", id, "comp", dbComp)
	return dbComp, nil
}
開發者ID:upwrd,項目名稱:sift,代碼行數:13,代碼來源:db.go


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