Exemplo n.º 1
0
func (q DbQueryer) MustRunSelectCommand(selectCommand *MysqlAst.SelectCommand) (mapValue []map[string]string) {
	output, paramList := selectCommand.GetPrepareParameter()
	list, error := q.Query(output, paramList...)
	if error != nil {
		panic(error)
	}
	return list
}
Exemplo n.º 2
0
func (page *KmgPage) runSelectCommand(selectCommand *MysqlAst.SelectCommand) *KmgPage {
	if page.BaseUrl == "" {
		panic("runSelectCommand need baseUrl parameter")
	}
	output, parameterList := selectCommand.GetPrepareParameter()
	countData, err := kmgSql.QueryOne("SELECT COUNT(*) AS c FROM ("+output+") as View", parameterList...)
	if err != nil {
		panic(err)
	}
	page.TotalItem, err = strconv.Atoi(countData["c"])
	if err != nil {
		panic(err)
	}
	dataSelect := selectCommand.Copy()
	dataSelect = dataSelect.Limit(strconv.Itoa(page.GetMysqlOffset()) + "," + strconv.Itoa(page.ItemPerPage))
	page.Data = kmgSql.MustRunSelectCommand(dataSelect)
	return page
}