gitee.com/curryzheng/dm@v0.0.1/t.go (about)

     1  /*
     2   * Copyright (c) 2000-2018, 达梦数据库有限公司.
     3   * All rights reserved.
     4   */
     5  package dm
     6  
     7  type DmResult struct {
     8  	filterable
     9  	dmStmt       *DmStatement
    10  	affectedRows int64
    11  	insertId     int64
    12  }
    13  
    14  func newDmResult(bs *DmStatement, execInfo *execRetInfo) *DmResult {
    15  	result := DmResult{}
    16  	result.resetFilterable(&bs.filterable)
    17  	result.dmStmt = bs
    18  	result.affectedRows = execInfo.updateCount
    19  	result.insertId = execInfo.lastInsertId
    20  	result.idGenerator = dmResultIDGenerator
    21  
    22  	return &result
    23  }
    24  
    25  /*************************************************************
    26   ** PUBLIC METHODS AND FUNCTIONS
    27   *************************************************************/
    28  func (r *DmResult) LastInsertId() (int64, error) {
    29  	//if err := r.dmStmt.checkClosed(); err != nil {
    30  	//	return -1, err
    31  	//}
    32  	if len(r.filterChain.filters) == 0 {
    33  		return r.lastInsertId()
    34  	}
    35  	return r.filterChain.reset().DmResultLastInsertId(r)
    36  }
    37  
    38  func (r *DmResult) RowsAffected() (int64, error) {
    39  	//if err := r.dmStmt.checkClosed(); err != nil {
    40  	//	return -1, err
    41  	//}
    42  	if len(r.filterChain.filters) == 0 {
    43  		return r.rowsAffected()
    44  	}
    45  	return r.filterChain.reset().DmResultRowsAffected(r)
    46  }
    47  
    48  func (result *DmResult) lastInsertId() (int64, error) {
    49  	return result.insertId, nil
    50  }
    51  
    52  func (result *DmResult) rowsAffected() (int64, error) {
    53  	return result.affectedRows, nil
    54  }