forked from go-sql-driver/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.go
More file actions
52 lines (44 loc) · 1.61 KB
/
result.go
File metadata and controls
52 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Go MySQL Sürücüsü - Go'nun database/sql paketi için bir MySQL Sürücüsü
//
// 2012 Go-MySQL-Driver Yazarlarının Tüm Hakları Saklıdır.
//
// Bu Kaynak Kod Formu, Mozilla Genel Kamu Lisansı, sürüm 2.0 şartlarına tabidir.
// MPL'nin bir kopyası bu dosya ile dağıtılmadıysa, http://mozilla.org/MPL/2.0/ adresinden edinebilirsiniz.
package mysql
import "database/sql/driver"
// Result, *connection.Result üzerinden erişilemeyen verileri ortaya çıkarır.
//
// Bu, sql.Conn.Raw() kullanılarak ve döndürülen sonucun aşağıya dökümü yapılarak erişilebilir:
//
// res, err := rawConn.Exec(...)
// res.(mysql.Result).AllRowsAffected()
type Result interface {
driver.Result
// AllRowsAffected, her yürütülen ifade için etkilenen satırları içeren bir dilim döndürür.
AllRowsAffected() []int64
// AllLastInsertIds, her yürütülen ifade için son eklenen kimliği içeren bir dilim döndürür.
AllLastInsertIds() []int64
}
type mysqlResult struct {
// Her yürütülen ifade sonucu için her iki dilimde bir giriş oluşturulur.
affectedRows []int64
insertIds []int64
}
func (res *mysqlResult) LastInsertId() (int64, error) {
if len(res.insertIds) == 0 {
return 0, nil
}
return res.insertIds[len(res.insertIds)-1], nil
}
func (res *mysqlResult) RowsAffected() (int64, error) {
if len(res.affectedRows) == 0 {
return 0, nil
}
return res.affectedRows[len(res.affectedRows)-1], nil
}
func (res *mysqlResult) AllLastInsertIds() []int64 {
return append([]int64{}, res.insertIds...)
}
func (res *mysqlResult) AllRowsAffected() []int64 {
return append([]int64{}, res.affectedRows...)
}