本文整理汇总了Golang中github.com/ziutek/mymysql/mysql.Conn.Start方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.Start方法的具体用法?Golang Conn.Start怎么用?Golang Conn.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ziutek/mymysql/mysql.Conn
的用法示例。
在下文中一共展示了Conn.Start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dumpTableData
// Get the table data
func dumpTableData(w io.Writer, db mysql.Conn, table string) {
fmt.Fprintf(w, "\n--\n-- Dumping data for table `%s`\n--\n\n", table)
rowCnt, _, err := db.QueryFirst(getSelectCountQueryFor(db, table))
checkError(err)
if rowCnt.Int(0) == 0 {
fmt.Fprintf(w, "--\n-- Empty table\n--\n\n")
return
} else {
fmt.Fprintf(w, "--\n-- %d rows\n--\n\n", rowCnt.Int(0))
}
fmt.Fprintf(w, "LOCK TABLES `%s` WRITE;\n", table)
query := fmt.Sprintf("INSERT INTO `%s` VALUES", table)
rows := make([]string, 0)
res, err := db.Start(getSelectQueryFor(db, table))
checkError(err)
row := res.MakeRow()
for {
err = res.ScanRow(row)
if err == io.EOF {
break
}
checkError(err)
vals := make([]string, 0)
for k, col := range row {
val := "NULL"
if col != nil {
val = fmt.Sprintf("'%s'", db.EscapeString(row.Str(k)))
}
vals = append(vals, val)
}
rows = append(rows, fmt.Sprintf("( %s )", strings.Join(vals, ", ")))
if len(rows) >= 100 {
fmt.Fprintf(w, "%s\n%s;\n", query, strings.Join(rows, ",\n"))
rows = make([]string, 0)
}
}
if len(rows) > 0 {
fmt.Fprintf(w, "%s\n%s;\n", query, strings.Join(rows, ",\n"))
}
fmt.Fprintf(w, "\nUNLOCK TABLES;\n")
}
示例2: AccountloginToo
func (this *DataModule) AccountloginToo(param *acc.LoginPlayer_MA, itbid int32, conn mysql.Conn) *AccParams {
str := fmt.Sprintf(`set @iisfcm = %d`, 1)
res, err := conn.Start(str)
if err != nil {
fmt.Println("存储过程调用失败", err.Error())
}
str = fmt.Sprintf(`set @iserverid = %d`, 0)
res, err = conn.Start(str)
if err != nil {
fmt.Println("存储过程调用失败", err.Error())
}
str = fmt.Sprintf(`call mfxy_accountlogin(%d,'%s','%s','%s','%s',@iserverid,%d,%d,%d,@iisfcm,@ifcmtime,@iaccid,@igmlevel,@igamepoints,@szprotectques,@szprotectansw,@iretval)`,
itbid, *param.SzAccount, *param.SzPassword, *param.SzIp, "haha", *param.ProductId, *param.PlatformId, *param.LoginType)
fmt.Println(str)
res, err = conn.Start(str)
if err != nil {
fmt.Println("存储过程调用失败", err.Error())
}
str = fmt.Sprintf(`select @iserverid,@iisfcm,@ifcmtime,@iaccid,@igmlevel,@igamepoints,@szprotectques,@szprotectansw,@iretval`)
fmt.Println(str)
res, err = conn.Start(str)
if err != nil {
fmt.Println("存储过程调用失败", err.Error())
}
row, _ := res.GetRow()
repParams := new(AccParams)
repParams.Serverid = uint64(row.Int(0))
repParams.Isfcm = uint32(row.Int(1))
repParams.Ifcmtime = uint64(row.Int64(2))
repParams.Accid = uint64(row.Int64(3))
repParams.Gmlevel = uint32(row.Int(4))
repParams.Points = uint64(row.Int(5))
repParams.Productid = uint64(row.Int64(6))
repParams.Protectansw = row.Str(7)
repParams.Iretval = int32(row.Int(8))
fmt.Println("datamodul end")
return repParams
}