How Insert with Bind param from Array to Mysql Using Go?

==> stmt.Exec()

this func get all value just one time, but i want set value in for(one and 
one).


    var values=args[1]
    var sql_first string="INSERT INTO "+table+" "
    var sql_end string=" VALUES("
    var sql_field string=""
    var items=values
    var count=len(items)
    if count >0{
        sql_field+="("
        for id,item := range items{
            sql_field+=item.Key
            sql_end+="?"
            if count-1 != id{
                sql_end+=","
                sql_field+=","
            }else{
                sql_field+=")"
                sql_end+=")"
            }
        }
    }
    var sql string=sql_first+sql_field+sql_end //now is = "INSERT INTO page 
(title,text) VALUES(?,?)"
    var stmt,err = DB.Prepare(sql)
    if err!=nil {
    }
    for _,item := range items{
        res,err := stmt.Exec( item.Value ) // how fix this?
    }

how fix `res,err := stmt.Exec( item.Value )` ?
please help me.



http://stackoverflow.com/questions/42595645/how-insert-with-bind-param-from-array-to-mysql-using-go

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to