Mysql: How Insert Query with Bind Param in Go?

Created on 2 Mar 2017  路  1Comment  路  Source: go-sql-driver/mysql

Hello
var sql string="INSERT INTO page (title,text) VALUES(?,?)"
var stmt,err = DB.Prepare(sql)
now can execute with : res,err := stmt.Exec("reckhou", "IT")

but i need a way to can set values as a array :
values=[]string{"reckhou", "IT"}
res,err := stmt.Exec(values)

please help me!

question

Most helpful comment

It must be an interface slice and you have to add ...
Try

values = []interface{"reckhou", "IT"}
res,err := stmt.Exec(values...)

>All comments

It must be an interface slice and you have to add ...
Try

values = []interface{"reckhou", "IT"}
res,err := stmt.Exec(values...)
Was this page helpful?
0 / 5 - 0 ratings