|
@ -23,7 +23,11 @@ func Insert(dbName, table string, data map[string]string) (int64, error) { |
|
|
if dbName == "" && table == "" { |
|
|
if dbName == "" && table == "" { |
|
|
return insertId, errors.New("没有数据表") |
|
|
return insertId, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if len(data) < 1 { |
|
|
if len(data) < 1 { |
|
|
return insertId, errors.New("没有要写入的数据") |
|
|
return insertId, errors.New("没有要写入的数据") |
|
@ -64,7 +68,11 @@ func Update(dbName, table string, data map[string]string, where map[string]strin |
|
|
return rowsAffected, errors.New("没有数据表") |
|
|
return rowsAffected, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
if len(data) < 1 { |
|
|
if len(data) < 1 { |
|
|
return rowsAffected, errors.New("同有更新的数据") |
|
|
return rowsAffected, errors.New("同有更新的数据") |
|
|
} |
|
|
} |
|
@ -124,8 +132,11 @@ func Delete(dbName, table string, data map[string]string, del_count ...string) ( |
|
|
return count, errors.New("没有数据表") |
|
|
return count, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
if len(data) < 1 { |
|
|
if len(data) < 1 { |
|
|
return count, errors.New("没有要删除的数据") |
|
|
return count, errors.New("没有要删除的数据") |
|
|
} |
|
|
} |
|
@ -292,8 +303,12 @@ func GetRow(dbName, table_name, alias string, titles string, join [][]string, wh |
|
|
return count, info, errors.New("没有数据表") |
|
|
return count, info, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
table := getTableName(dbName, table_name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table := "" |
|
|
|
|
|
if strings.Contains(table_name, "select ") { |
|
|
|
|
|
table = table_name |
|
|
|
|
|
} else { |
|
|
|
|
|
table = getTableName(dbName, table_name) |
|
|
|
|
|
} |
|
|
var sql_str, title string |
|
|
var sql_str, title string |
|
|
|
|
|
|
|
|
if titles != "" { |
|
|
if titles != "" { |
|
@ -431,8 +446,12 @@ func FetchRows(dbName, table_name, alias string, titles string, join [][]string, |
|
|
if dbName == "" && table_name == "" { |
|
|
if dbName == "" && table_name == "" { |
|
|
return count, list, errors.New("没有数据表") |
|
|
return count, list, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
table := getTableName(dbName, table_name) |
|
|
|
|
|
|
|
|
table := "" |
|
|
|
|
|
if strings.Contains(table_name, "select ") { |
|
|
|
|
|
table = table_name |
|
|
|
|
|
} else { |
|
|
|
|
|
table = getTableName(dbName, table_name) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var sql_str, title string |
|
|
var sql_str, title string |
|
|
|
|
|
|
|
@ -598,8 +617,11 @@ func GetList(dbName, table string, title string, where map[string]string, limit |
|
|
return list, errors.New("没有数据表") |
|
|
return list, errors.New("没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
var rows *sql.Rows |
|
|
var rows *sql.Rows |
|
|
var err error |
|
|
var err error |
|
|
var queryNum int = 0 |
|
|
var queryNum int = 0 |
|
@ -722,7 +744,11 @@ func GetTotal(dbName, table string, args ...string) (total int) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var title string = "*" |
|
|
var title string = "*" |
|
|
|
|
|
|
|
@ -776,7 +802,11 @@ func GetCount(dbName, table string, where map[string]string, args ...string) (to |
|
|
if dbName == "" && table == "" { |
|
|
if dbName == "" && table == "" { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
|
|
|
if strings.Contains(table, "select ") { |
|
|
|
|
|
dbName = table |
|
|
|
|
|
} else { |
|
|
|
|
|
dbName = getTableName(dbName, table) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var title string = "*" |
|
|
var title string = "*" |
|
|
|
|
|
|
|
|