Beispiel #1
0
func (ms *MySQL) getSimpleSQL2(id int) ([]map[string]interface{}, error) {
	sql := `SELECT user_id, first_name, last_name, create_datetime FROM t_users WHERE delete_flg=?`

	data, _, err := ms.Db.Select(sql, 1)
	if err != nil {
		return nil, err
	} else if len(data) == 0 {
		return nil, u.Stoe("No data.")
	}
	return data, nil
}
Beispiel #2
0
// Get User List
func (ms *MySQL) getUserList() ([]map[string]interface{}, error) {
	sql := "SELECT user_id, first_name, last_name, create_datetime FROM t_users WHERE delete_flg=?"
	data, _, err := ms.Db.Select(sql, 0)
	if err != nil {
		return nil, err
	} else if len(data) == 0 {
		//lg.Info("No data.")
		return nil, u.Stoe("No data.")
	}
	return data, nil
}
Beispiel #3
0
// Get User List(Using Cache)
func (ms *MySQL) getUserListOnCache() ([]map[string]interface{}, error) {
	var cacheKey string = "sql001"

	//check cache data
	if value, ok := cacheData[cacheKey]; ok {
		return value, nil
	}

	sql := "SELECT user_id, first_name, last_name, create_datetime FROM t_users WHERE delete_flg=?"
	data, _, err := ms.Db.Select(sql, 0)
	if err != nil {
		return nil, err
	} else if len(data) == 0 {
		return nil, u.Stoe("No data.")
	}
	//set chache
	cacheData[cacheKey] = data

	return data, nil
}