scan query question #1141

Open
opened 2018-11-12 09:27:50 +00:00 by edwinchana · 2 comments
edwinchana commented 2018-11-12 09:27:50 +00:00 (Migrated from github.com)

Can I use scan to pass multiple variable pointer instead of passing struct pointer?
Because I pass structure pointer to scan function, it will cause lower performance when use reflect to set value

Can I use scan to pass multiple variable pointer instead of passing struct pointer? Because I pass structure pointer to scan function, it will cause lower performance when use reflect to set value
Member

Do you mean something like following?

cols := []string{"col1","col2","col3"} 
var valuesSlice = make([]interface{}, len(cols))  
has, err := engine.Where("id = ?", id).Cols(cols...).Get(&valuesSlice)
Do you mean something like following? ``` cols := []string{"col1","col2","col3"} var valuesSlice = make([]interface{}, len(cols)) has, err := engine.Where("id = ?", id).Cols(cols...).Get(&valuesSlice) ```
edwinchana commented 2018-11-22 08:25:44 +00:00 (Migrated from github.com)

I want to implement like following

type User struct {
	Id       int64
	Name     string  
}
var u User
err = rows.Scan(&u.Id, &u.Name)

but xorm provide get and find method to use. it will use reflect to set value.
like following
err := engine.Where("id = ?", id).Get(&user)

can I use rows.scan method in xorm ?

I want to implement like following ``` type User struct { Id int64 Name string } var u User err = rows.Scan(&u.Id, &u.Name) ``` but xorm provide get and find method to use. it will use reflect to set value. like following `err := engine.Where("id = ?", id).Get(&user)` can I use rows.scan method in xorm ?
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1141
No description provided.