package tencentdb
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
)
|
|
|
|
func Test_Connet(t *testing.T) {
|
|
//go func() {
|
|
for i := 0; i < 1; i++ {
|
|
dbhost := "localhost"
|
|
dbname := "shop"
|
|
dbusername := "tetele"
|
|
dbpassword := "fly123456"
|
|
dbport := "3306"
|
|
table := "ttl_order_product"
|
|
err := Connect(dbhost, dbusername, dbpassword, dbname, dbport)
|
|
|
|
if err != nil {
|
|
log.Println(err.Error())
|
|
}
|
|
|
|
//_,err = new(Query).Db(dbname).Table("ttl_user").Where("id > 0").Select()
|
|
|
|
// _, err = new(Query).Db(dbname).Table("ttl_news").
|
|
// Datas([]string{"title=?", "content=?"}).
|
|
// Values([]interface{}{"aaaaaaaaa", "bbbbbb"}).Create()
|
|
|
|
title := "op.id,op.sn,op.order_price"
|
|
alias := "op"
|
|
join := [][]string{}
|
|
join = append(join, []string{"ttl_product as p", "op.product_id=p.id"})
|
|
where := []string{}
|
|
where_or := []string{}
|
|
valueList := []interface{}{}
|
|
orderby := "id desc"
|
|
debug := true
|
|
|
|
// count, row, err := GetRow(dbname, table, alias, title, join, where, where_or, valueList, orderby, debug)
|
|
count, row, err := FetchRows(dbname, table, alias, title, join, where, where_or, valueList, orderby, 1, 10, debug)
|
|
|
|
log.Println(count)
|
|
log.Println(row)
|
|
log.Println(err)
|
|
if err != nil {
|
|
log.Println(err.Error())
|
|
}
|
|
}
|
|
//}()
|
|
|
|
}
|