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


Golang db.MConn類代碼示例

本文整理匯總了Golang中ftnox/com/db.MConn的典型用法代碼示例。如果您正苦於以下問題:Golang MConn類的具體用法?Golang MConn怎麽用?Golang MConn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: UpdatePayment

func UpdatePayment(c db.MConn, p *Payment) {
	p.Updated = time.Now().Unix()
	_, err := c.Exec(
		`UPDATE payment SET blockhash=?, blockheight=?, orphaned=?, time=?, updated=? WHERE tx_id=? AND vout=?`,
		p.Blockhash, p.Blockheight, p.Orphaned, p.Time, p.Updated, p.TxId, p.Vout,
	)
	if err != nil {
		panic(err)
	}
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:10,代碼來源:models.go

示例2: SaveBalance

func SaveBalance(c db.MConn, balance *Balance) *Balance {
	_, err := c.Exec(
		`INSERT INTO account_balance (`+BalanceModel.FieldsInsert+`)
         VALUES (`+BalanceModel.Placeholders+`)`,
		balance,
	)
	if err != nil {
		panic(err)
	}
	return balance
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:11,代碼來源:models.go

示例3: SavePayment

func SavePayment(c db.MConn, p *Payment) (*Payment, error) {
	if p.Time == 0 {
		p.Time = time.Now().Unix()
	}
	err := c.QueryRow(
		`INSERT INTO payment (`+PaymentModel.FieldsInsert+`)
         VALUES (`+PaymentModel.Placeholders+`)
         RETURNING id`,
		p,
	).Scan(&p.Id)
	return p, err
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:12,代碼來源:models.go

示例4: LoadWithdrawalsByStatus

func LoadWithdrawalsByStatus(c db.MConn, coin string, status int32, limit uint) []*Withdrawal {
	rows, err := c.QueryAll(Withdrawal{},
		`SELECT `+WithdrawalModel.FieldsSimple+`
         FROM account_withdrawal
         WHERE status=? AND coin=?
         ORDER BY id ASC LIMIT ?`,
		status, coin, limit,
	)
	if err != nil {
		panic(err)
	}
	return rows.([]*Withdrawal)
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:13,代碼來源:models.go

示例5: LoadWithdrawal

func LoadWithdrawal(c db.MConn, id int64) *Withdrawal {
	var wth Withdrawal
	err := c.QueryRow(
		`SELECT `+WithdrawalModel.FieldsSimple+`
         FROM account_withdrawal
         WHERE id=?`,
		id,
	).Scan(&wth)
	if err != nil {
		panic(err)
	}
	return &wth
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:13,代碼來源:models.go

示例6: LoadDepositForPayment

func LoadDepositForPayment(c db.MConn, paymentId int64) *Deposit {
	var dep Deposit
	err := c.QueryRow(
		`SELECT `+DepositModel.FieldsSimple+`
         FROM account_deposit
         WHERE payment_id=?`,
		paymentId,
	).Scan(&dep)
	if err != nil {
		panic(err)
	}
	return &dep
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:13,代碼來源:models.go

示例7: SaveDeposit

// Might throw an error if the deposit already exists.
func SaveDeposit(c db.MConn, dep *Deposit) (*Deposit, error) {
	if dep.Time == 0 {
		dep.Time = time.Now().Unix()
	}
	// Add to DB
	err := c.QueryRow(
		`INSERT INTO account_deposit (`+DepositModel.FieldsInsert+`)
         VALUES (`+DepositModel.Placeholders+`)
         RETURNING id`,
		dep,
	).Scan(&dep.Id)
	return dep, err
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:14,代碼來源:models.go

示例8: SaveTransfer

func SaveTransfer(c db.MConn, trans *Transfer) *Transfer {
	if trans.Time == 0 {
		trans.Time = time.Now().Unix()
	}
	err := c.QueryRow(
		`INSERT INTO account_transfer (`+TransferModel.FieldsInsert+`)
         VALUES (`+TransferModel.Placeholders+`)
         RETURNING id`,
		trans,
	).Scan(&trans.Id)
	if err != nil {
		panic(err)
	}
	return trans
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:15,代碼來源:models.go

示例9: SaveWithdrawal

func SaveWithdrawal(c db.MConn, wth *Withdrawal) *Withdrawal {
	if wth.Time == 0 {
		wth.Time = time.Now().Unix()
	}
	// Add to DB
	err := c.QueryRow(
		`INSERT INTO account_withdrawal (`+WithdrawalModel.FieldsInsert+`)
         VALUES (`+WithdrawalModel.Placeholders+`)
         RETURNING id`,
		wth,
	).Scan(&wth.Id)
	if err != nil {
		panic(err)
	}
	return wth
}
開發者ID:jaekwon,項目名稱:ftnox-backend,代碼行數:16,代碼來源:models.go


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