|
|
@ -179,7 +179,7 @@ func (this *Query) Clean() *Query { |
|
|
|
return this |
|
|
|
} |
|
|
|
|
|
|
|
//获取表格信息
|
|
|
|
// 获取表格信息
|
|
|
|
func (this *Query) GetTableInfo(table string) (map[string]interface{}, error) { |
|
|
|
field := []string{ |
|
|
|
"COLUMN_NAME", //字段名
|
|
|
@ -245,7 +245,7 @@ func (this *Query) GetTableInfo(table string) (map[string]interface{}, error) { |
|
|
|
}, nil |
|
|
|
} |
|
|
|
|
|
|
|
//构造子查询
|
|
|
|
// 构造子查询
|
|
|
|
func (this *Query) BuildSelectSql() (map[string]interface{}, error) { |
|
|
|
if this.dbname == "" && this.table == "" { |
|
|
|
return nil, errors.New("参数错误,没有数据表") |
|
|
@ -266,12 +266,23 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) { |
|
|
|
} else { |
|
|
|
title = "*" |
|
|
|
} |
|
|
|
if DB_PROVIDER == "TencentDB" { |
|
|
|
sql = helper.StringJoin("/*slave*/ select ", title) |
|
|
|
|
|
|
|
if this.dbtype == "mssql" { |
|
|
|
if this.page_size > 0 { |
|
|
|
sql = helper.StringJoin("select top ", helper.ToStr(this.page_size), " ") |
|
|
|
} else { |
|
|
|
sql = "select " |
|
|
|
} |
|
|
|
} else { |
|
|
|
sql = helper.StringJoin("select ", title) |
|
|
|
if DB_PROVIDER == "TencentDB" { |
|
|
|
sql = "/*slave*/ select " |
|
|
|
} else { |
|
|
|
sql = "select " |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sql = helper.StringJoin(sql, title) |
|
|
|
|
|
|
|
if this.alias != "" { |
|
|
|
table = helper.StringJoin(table, " as ", this.alias) |
|
|
|
} |
|
|
@ -315,7 +326,7 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) { |
|
|
|
sql = helper.StringJoin(sql, " order by ", this.orderby) |
|
|
|
} |
|
|
|
|
|
|
|
if this.page > 0 || this.page_size > 0 { |
|
|
|
if this.dbtype == "mysql" && (this.page > 0 || this.page_size > 0) { |
|
|
|
|
|
|
|
if this.page < 1 { |
|
|
|
this.page = 1 |
|
|
@ -358,7 +369,11 @@ func (this *Query) QueryStmt() error { |
|
|
|
|
|
|
|
if SLAVER_DB != nil { |
|
|
|
this.conn = SLAVER_DB |
|
|
|
} else { |
|
|
|
} |
|
|
|
// else {
|
|
|
|
// this.conn = DB
|
|
|
|
// }
|
|
|
|
if this.conn == nil { |
|
|
|
this.conn = DB |
|
|
|
} |
|
|
|
|
|
|
@ -798,7 +813,7 @@ func (this *Query) Update() (int64, error) { |
|
|
|
return StmtForUpdateExec(this.stmt, this.value) |
|
|
|
} |
|
|
|
|
|
|
|
//批量更新
|
|
|
|
// 批量更新
|
|
|
|
func (this *Query) UpdateAll() (int64, error) { |
|
|
|
|
|
|
|
err := this.UpdateAllStmt() |
|
|
|