Exemplo n.º 1
0
func (connection *Connection) ExecuteGet(query *Query) SearchResult {
	list := C.xtcrdb_qrysearchget(query.Tyrant)
	list_size := int(C.xtc_listnum(list))
	fmt.Printf("list size: %d\n", list_size)
	rows := make([]Row, list_size)
	for i := 0; i < list_size; i++ {
		cols := C.xtcrdb_qryrescols(list, C.int(i))
		if cols != nil {
			var row Row
			row.Data = make(ColumnMap)
			// row.Data["PKEY"] = C.GoString(pk);
			C.xtc_mapiterinit(cols)
			name := C.xtc_mapiternext2(cols)
			for name != nil {
				row.Data[C.GoString(name)] = C.GoString(C.xtc_mapget2(cols, name))
				name = C.xtc_mapiternext2(cols)
			}
			rows[i] = row
		}
	}
	var result SearchResult
	result.Rows = rows
	result.Count = list_size
	return result
}
Exemplo n.º 2
0
func (connection *Connection) Get(primaryKey string) *ColumnMap {
	cols := C.xtcrdb_tblget(connection.Tyrant, C.CString(primaryKey))
	if cols == nil {
		return nil
	}

	result := make(ColumnMap)
	result["PKEY"] = primaryKey
	C.xtc_mapiterinit(cols)
	name := C.xtc_mapiternext2(cols)
	for name != nil {
		result[C.GoString(name)] = C.GoString(C.xtc_mapget2(cols, name))
		name = C.xtc_mapiternext2(cols)
	}
	return &result
}