示例#1
0
文件: sqlite.go 项目: kazyk/go-sqlite
func (stmt Stmt) Exec(args []driver.Value) (driver.Result, error) {
	if err := stmt.bind(args); err != nil {
		return nil, err
	}

	r := C.sqlite3_step(stmt.stmt)
	db := C.sqlite3_db_handle(stmt.stmt)

	if r != C.SQLITE_DONE && r != C.SQLITE_ROW {
		return nil, dbError(db)
	}

	var result Result
	result.rowsAffected = int64(C.sqlite3_changes(db))
	result.lastInsertId = int64(C.sqlite3_last_insert_rowid(db))
	return &result, nil
}
示例#2
0
文件: sqlite.go 项目: kazyk/go-sqlite
func stmtError(stmt *C.sqlite3_stmt) error {
	return dbError(C.sqlite3_db_handle(stmt))
}