November 2018
Intermediate to advanced
346 pages
8h 12m
English
A quick reminder, the data package is a data access layer (DAL) that provides simplified and abstracted access to the underlying MySQL database.
The following is the current code for the Save() function:
// Save will save the supplied person and return the ID of the newly // created person or an error.// Errors returned are caused by the underlying database or our // connection to it.func Save(in *Person) (int, error) { db, err := getDB() if err != nil { logging.L.Error("failed to get DB connection. err: %s", err) return defaultPersonID, err } // perform DB insert result, err := db.Exec(sqlInsert, in.FullName, in.Phone, in.Currency, in.Price) if err != nil { logging.L.Error("failed to save person ...
Read now
Unlock full access