当前位置: 首页>>代码示例>>Golang>>正文


Golang Conn.Start方法代码示例

本文整理汇总了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")
}
开发者ID:sirishkumar,项目名称:mysqlsuperdump,代码行数:50,代码来源:mysqlsuperdump.go

示例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
}
开发者ID:jmptrader,项目名称:messageEngine,代码行数:43,代码来源:roleDao.go


注:本文中的github.com/ziutek/mymysql/mysql.Conn.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。