예제 #1
0
파일: db.go 프로젝트: keep94/appcommon
// LastRowId returns the Id of the last inserted row in database.
func LastRowId(conn *sqlite.Conn) (id int64, err error) {
	stmt, err := conn.Prepare(LastRowIdSQL)
	if err != nil {
		return
	}
	defer stmt.Finalize()
	return LastRowIdFromStmt(stmt)
}
예제 #2
0
파일: db.go 프로젝트: keep94/appcommon
// ReadMultiple executes sql and reads multiple rows.
// consumer may consume either business objects or db.Etagger objects.
// For the latter case, row must also implement RowForWriting
func ReadMultiple(
	conn *sqlite.Conn,
	row RowForReading,
	consumer functional.Consumer,
	sql string,
	params ...interface{}) error {
	stmt, err := conn.Prepare(sql)
	if err != nil {
		return err
	}
	defer stmt.Finalize()
	if err = stmt.Exec(params...); err != nil {
		return err
	}
	return consumer.Consume(ReadRows(row, stmt))
}