func (stmt *GetRowStmt) Get(db DB, dest interface{}) (int, error) {
	stmt.initOnce()
	if stmt.err != nil {
		return 0, stmt.err
	}
	errorPtrType := func() error {
		expectedTypeName := stmt.expectedTypeName()
		return fmt.Errorf("expected dest to be *%s", expectedTypeName)
	}

	destValue := reflect.ValueOf(dest)

	if destValue.Kind() != reflect.Ptr {
		return 0, errorPtrType()
	}
	if destValue.IsNil() {
		return 0, errors.New("nil pointer passed")
	}

	rowValue := reflect.Indirect(destValue)
	rowType := rowValue.Type()
	if rowType != stmt.rowType {
		return 0, errorPtrType()
	}

	args, err := stmt.getArgs(dest)
	if err != nil {
		return 0, err
	}

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

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

	var rowCount = 0
	defer func() {
		stmt.logSuccess(args, rowCount)
	}()

	if !rows.Next() {
		// no rows returned
		return 0, nil
	}

	// at least one row returned
	rowCount++

	for i, col := range stmt.outputs {
		cellValue := col.Index.ValueRW(rowValue)
		scanValues[i] = cellValue.Addr().Interface()
	}
	err = rows.Scan(scanValues...)
	if err != nil {
		return 0, err
	}

	// count any additional rows
	for rows.Next() {
		rowCount++
	}

	return rowCount, nil
}
// Get a single row into dest based on the fields populated in dest.
Get a single row into dest based on the fields populated in dest.
// Get a single row into dest based on the fields populated in dest .
func (stmt *GetRowStmt) Get(db DB, dest interface{}) (int, error) {
	stmt.initOnce()
	if stmt.err != nil {
		return 0, stmt.err
	}
	errorPtrType := func() error {
		expectedTypeName := stmt.expectedTypeName()
		return fmt.Errorf("expected dest to be *%s", expectedTypeName)
	}
	destValue := reflect.ValueOf(dest)
	if destValue.Kind() != reflect.Ptr {
		return 0, errorPtrType()
	}
	if destValue.IsNil() {
		return 0, errors.New("nil pointer passed")
	}
	rowValue := reflect.Indirect(destValue)
	rowType := rowValue.Type()
	if rowType != stmt.rowType {
		return 0, errorPtrType()
	}
	args, err := stmt.getArgs(dest)
	if err != nil {
		return 0, err
	}
	rows, err := db.Query(stmt.query, args...)
	if err != nil {
		stmt.logError(args, err)
		return 0, err
	}
	defer rows.Close()
	scanValues := make([]interface{}, len(stmt.outputs))
	var rowCount = 0
	defer func() {
		stmt.logSuccess(args, rowCount)
	}()
	if !rows.Next() {
		return 0, nil
	}
	rowCount++
	for i, col := range stmt.outputs {
		cellValue := col.Index.ValueRW(rowValue)
		scanValues[i] = cellValue.Addr().Interface()
	}
	err = rows.Scan(scanValues...)
	if err != nil {
		return 0, err
	}
	for rows.Next() {
		rowCount++
	}
	return rowCount, nil
}
func ( stmt * GetRowStmt ) Get ( db DB , dest interface { } ) ( int , error ) { stmt . initOnce ( ) if stmt . err != nil { return 0 , stmt . err } errorPtrType := func ( ) error { expectedTypeName := stmt . expectedTypeName ( ) return fmt . Errorf ( " " , expectedTypeName ) } destValue := reflect . ValueOf ( dest ) if destValue . Kind ( ) != reflect . Ptr { return 0 , errorPtrType ( ) } if destValue . IsNil ( ) { return 0 , errors . New ( " " ) } rowValue := reflect . Indirect ( destValue ) rowType := rowValue . Type ( ) if rowType != stmt . rowType { return 0 , errorPtrType ( ) } args , err := stmt . getArgs ( dest ) if err != nil { return 0 , err } rows , err := db . Query ( stmt . query , args ... ) if err != nil { stmt . logError ( args , err ) return 0 , err } defer rows . Close ( ) scanValues := make ( [ ] interface { } , len ( stmt . outputs ) ) var rowCount = 0 defer func ( ) { stmt . logSuccess ( args , rowCount ) } ( ) if ! rows . Next ( ) { return 0 , nil } rowCount ++ for i , col := range stmt . outputs { cellValue := col . Index . ValueRW ( rowValue ) scanValues [ i ] = cellValue . Addr ( ) . Interface ( ) } err = rows . Scan ( scanValues ... ) if err != nil { return 0 , err } for rows . Next ( ) { rowCount ++ } return rowCount , nil }
Get a single row into dest based on the fields populated in dest.
Get a single row into dest based on the fields populated in dest .
// no rows returned // at least one row returned // count any additional rows