This commit is contained in:
aozhiwei 2023-08-14 13:59:50 +08:00
parent 7c4682d82b
commit 7e8d448ef7

View File

@ -11,6 +11,7 @@ type DataSet struct {
} }
func (this *DataSet) Next() bool { func (this *DataSet) Next() bool {
ret := this.rows.Next()
this.GetColumns() this.GetColumns()
this.values = []interface{}{} this.values = []interface{}{}
for i := 0 ; i < len(this.columns); i++ { for i := 0 ; i < len(this.columns); i++ {
@ -18,7 +19,7 @@ func (this *DataSet) Next() bool {
this.values = append(this.values, &str) this.values = append(this.values, &str)
} }
this.rows.Scan(this.values...) this.rows.Scan(this.values...)
return this.rows.Next() return ret
} }
func (this *DataSet) GetColumns() []string { func (this *DataSet) GetColumns() []string {
@ -32,6 +33,7 @@ func (this *DataSet) GetColumns() []string {
} }
func (this *DataSet) GetByName(name string) *string { func (this *DataSet) GetByName(name string) *string {
this.GetColumns()
for i := 0; i < len(this.columns); i++ { for i := 0; i < len(this.columns); i++ {
if this.columns[i] == name { if this.columns[i] == name {
return this.GetByIndex(int32(i)) return this.GetByIndex(int32(i))
@ -41,6 +43,7 @@ func (this *DataSet) GetByName(name string) *string {
} }
func (this *DataSet) GetByIndex(index int32) *string { func (this *DataSet) GetByIndex(index int32) *string {
this.GetColumns()
return this.values[index].(*string); return this.values[index].(*string);
} }