func (m xxxstruct) insertxxx() (bool,string){
sqlquery :="insert into tables_name(id,name,email,content,) values(%v,%v,%v,%v)"
sqlquery =fmt.Sprintf(sqlquery,m.id,m.name,m.email,m.content)
ok,desc :=queryexecmysql(sqlquery)
if ok {
return false,desc
}
return true,"ok"
}
func queryexecmysql(parmam string)(bool string){
o :=orm.NewOrm()
o.Using("deafult")
_,err :=o.Raw(parmam).Exec()
if err !=nil ||err ==orm.ErrNORow{
log.Error(err)
return false,"error:"+err.Error()
}
return true,"ok"
}
有疑问加站长微信联系(非本文作者)