func (stmt *SelectStmt) Select(db DB, dest interface{}, args ...interface{}) error {
	stmt.initOnce()
	if stmt.err != nil {
		return stmt.err
	}
	destValue := reflect.ValueOf(dest)

	if destValue.Kind() != reflect.Ptr {
		return stmt.errorSliceType()
	}
	if destValue.IsNil() {
		return errors.New("Select: nil pointer passed as dest")
	}

	sliceValue := reflect.Indirect(destValue)
	sliceType := sliceValue.Type()
	if sliceType.Kind() != reflect.Slice {
		return stmt.errorSliceType()
	}

	rowType := sliceType.Elem()
	isPtr := rowType.Kind() == reflect.Ptr
	if isPtr {
		rowType = rowType.Elem()
	}
	if rowType != stmt.rowType {
		return stmt.errorSliceType()
	}

	rows, err := db.Query(stmt.query, args...)
	if err != nil {
		stmt.logError(args, err)
		return err
	}
	defer rows.Close()

	var rowCount = 0
	if stmt.Logger != nil {
		defer func() {
			stmt.logSuccess(args, rowCount)
		}()
	}

	scanValues := make([]interface{}, len(stmt.columns))

	for rows.Next() {
		rowCount++
		rowValuePtr := reflect.New(rowType)
		rowValue := reflect.Indirect(rowValuePtr)
		for i, col := range stmt.columns {
			cellValue := col.Index.ValueRW(rowValue)
			scanValues[i] = cellValue.Addr().Interface()
		}
		err = rows.Scan(scanValues...)
		if err != nil {
			return err
		}
		if isPtr {
			sliceValue.Set(reflect.Append(sliceValue, rowValuePtr))
		} else {
			sliceValue.Set(reflect.Append(sliceValue, rowValue))
		}
	}

	return rows.Err()
}
// Select executes the statement's query and returns the resulting
// rows in the slice pointed to by dest. The args are for any
// placeholder parameters in the query.
Select executes the statement's query and returns the resulting
rows in the slice pointed to by dest. The args are for any
placeholder parameters in the query.
// Select executes the statement ' s query and returns the resulting // rows in the slice pointed to by dest . The args are for any // placeholder parameters in the query .
func (stmt *SelectStmt) Select(db DB, dest interface{}, args ...interface{}) error {
	stmt.initOnce()
	if stmt.err != nil {
		return stmt.err
	}
	destValue := reflect.ValueOf(dest)
	if destValue.Kind() != reflect.Ptr {
		return stmt.errorSliceType()
	}
	if destValue.IsNil() {
		return errors.New("Select: nil pointer passed as dest")
	}
	sliceValue := reflect.Indirect(destValue)
	sliceType := sliceValue.Type()
	if sliceType.Kind() != reflect.Slice {
		return stmt.errorSliceType()
	}
	rowType := sliceType.Elem()
	isPtr := rowType.Kind() == reflect.Ptr
	if isPtr {
		rowType = rowType.Elem()
	}
	if rowType != stmt.rowType {
		return stmt.errorSliceType()
	}
	rows, err := db.Query(stmt.query, args...)
	if err != nil {
		stmt.logError(args, err)
		return err
	}
	defer rows.Close()
	var rowCount = 0
	if stmt.Logger != nil {
		defer func() {
			stmt.logSuccess(args, rowCount)
		}()
	}
	scanValues := make([]interface{}, len(stmt.columns))
	for rows.Next() {
		rowCount++
		rowValuePtr := reflect.New(rowType)
		rowValue := reflect.Indirect(rowValuePtr)
		for i, col := range stmt.columns {
			cellValue := col.Index.ValueRW(rowValue)
			scanValues[i] = cellValue.Addr().Interface()
		}
		err = rows.Scan(scanValues...)
		if err != nil {
			return err
		}
		if isPtr {
			sliceValue.Set(reflect.Append(sliceValue, rowValuePtr))
		} else {
			sliceValue.Set(reflect.Append(sliceValue, rowValue))
		}
	}
	return rows.Err()
}
func ( stmt * SelectStmt ) Select ( db DB , dest interface { } , args ... interface { } ) error { stmt . initOnce ( ) if stmt . err != nil { return stmt . err } destValue := reflect . ValueOf ( dest ) if destValue . Kind ( ) != reflect . Ptr { return stmt . errorSliceType ( ) } if destValue . IsNil ( ) { return errors . New ( " " ) } sliceValue := reflect . Indirect ( destValue ) sliceType := sliceValue . Type ( ) if sliceType . Kind ( ) != reflect . Slice { return stmt . errorSliceType ( ) } rowType := sliceType . Elem ( ) isPtr := rowType . Kind ( ) == reflect . Ptr if isPtr { rowType = rowType . Elem ( ) } if rowType != stmt . rowType { return stmt . errorSliceType ( ) } rows , err := db . Query ( stmt . query , args ... ) if err != nil { stmt . logError ( args , err ) return err } defer rows . Close ( ) var rowCount = 0 if stmt . Logger != nil { defer func ( ) { stmt . logSuccess ( args , rowCount ) } ( ) } scanValues := make ( [ ] interface { } , len ( stmt . columns ) ) for rows . Next ( ) { rowCount ++ rowValuePtr := reflect . New ( rowType ) rowValue := reflect . Indirect ( rowValuePtr ) for i , col := range stmt . columns { cellValue := col . Index . ValueRW ( rowValue ) scanValues [ i ] = cellValue . Addr ( ) . Interface ( ) } err = rows . Scan ( scanValues ... ) if err != nil { return err } if isPtr { sliceValue . Set ( reflect . Append ( sliceValue , rowValuePtr ) ) } else { sliceValue . Set ( reflect . Append ( sliceValue , rowValue ) ) } } return rows . Err ( ) }
Select executes the statement's query and returns the resulting
rows in the slice pointed to by dest.
Select executes the statement ' s query and returns the resulting rows in the slice pointed to by dest .