12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package sql
- // TableRow 数据库表行
- type TableRow struct {
- columns []string
- values []any
- err error
- }
- // NewTableRow 创建数据库表行
- func NewTableRow() *TableRow {
- return &TableRow{
- columns: make([]string, 0),
- values: make([]any, 0),
- }
- }
- // Add 添加表行
- // 参数:
- // - column: 列名
- // - value: 列值
- // 返回值:
- // - 数据库表行
- func (tableRow *TableRow) Add(column string, value any) *TableRow {
- if tableRow.err != nil {
- return tableRow
- }
- tableRow.columns = append(tableRow.columns, "\""+column+"\"")
- tableRow.values = append(tableRow.values, value)
- return tableRow
- }
- // Columns 获取添加的列名
- // 参数: 无
- // 返回值:
- // - 添加的列名
- func (tableRow *TableRow) Columns() []string {
- return tableRow.columns
- }
- // Values 获取添加的列值
- // 参数: 无
- // 返回值:
- // - 添加的列值
- func (tableRow *TableRow) Values() []any {
- return tableRow.values
- }
|