Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 11, 2018 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/f03f338be4fde8258ee04d234e24ead5 to your computer and use it in GitHub Desktop.
Save parzibyte/f03f338be4fde8258ee04d234e24ead5 to your computer and use it in GitHub Desktop.
func actualizar(c Contacto) error {
db, err := obtenerBaseDeDatos()
if err != nil {
return err
}
defer db.Close()
sentenciaPreparada, err := db.Prepare("UPDATE agenda SET nombre = ?, direccion = ?, correo_electronico = ? WHERE id = ?")
if err != nil {
return err
}
defer sentenciaPreparada.Close()
// Pasar argumentos en el mismo orden que la consulta
_, err = sentenciaPreparada.Exec(c.Nombre, c.Direccion, c.CorreoElectronico, c.Id)
return err // Ya sea nil o sea un error, lo manejaremos desde donde hacemos la llamada
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment