MCPcopy Create free account
hub / github.com/kataras/iris / Get

Method Get

_examples/database/mysql/sql/mysql.go:102–117  ·  view source on GitHub ↗

Get same as `Select` but it moves the cursor to the first result.

(ctx context.Context, dest interface{}, query string, args ...interface{})

Source from the content-addressed store, hash-verified

100
101// Get same as `Select` but it moves the cursor to the first result.
102func (db *MySQL) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
103 rows, err := db.Conn.QueryContext(ctx, query, args...)
104 if err != nil {
105 return err
106 }
107 defer rows.Close()
108 if !rows.Next() {
109 return ErrNoRows
110 }
111
112 if scannable, ok := dest.(Scannable); ok {
113 return scannable.Scan(rows)
114 }
115
116 return rows.Scan(dest)
117}
118
119// Exec executes a query. It does not return any rows.
120// Use the first output parameter to count the affected rows on UPDATE, INSERT, or DELETE.

Callers

nothing calls this directly

Calls 3

NextMethod · 0.80
CloseMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected