9.1 结果集类

所有数据库操作都会返回一个结果。返回的结果类型取决于执行的操作。下表概述了不同类型的结果。

表 9.1 结果类及其提供的信息

结果类

返回者

提供

Result

add().execute()insert().execute()modify().execute()update().execute()remove().execute()delete().execute()

受操作影响的行数、自动生成的文档 ID、最后自动生成的 AUTO INCREMENT 列值或警告,具体取决于返回 Result 的操作。

SqlResult

session.sql().execute()

受操作影响的行数、自动生成的文档 ID、最后自动生成的 AUTO INCREMENT 列值、警告或获取的数据集,具体取决于返回 SqlResult 的操作。

DocResult

find().execute()

获取的数据集

RowResult

select.execute()

获取的数据集


以下类图简要概述了结果类及其函数。

图 9.1 结果类

In the following functions, square brackets indicate a list of items. This can be any appropriate list type in the target language (an array, a collection, and so on). The BaseResults class contains the following functions: getWarnings(): Warning[] and getWarningsCount(): int, which are diagnostics functions. The Result class contains the following functions: getAffectedItemsCount(): int, getAutoIncrementValue(): int, getGeneratedIds(): String[], which are data change information functions. The DocResult class contains the following functions: fetchAll(): Document[] and fetchOne(): Document, which are document access functions. The RowResult class contains the following functions: fetchAll(): Row[], fetchOne(): Row, getColumns(): Column[], and nextResult(): boolean. The SqlResult class contains the following functions: hasData(): boolean, getAffectedItemsCount(): int, and getAutoIncrementValue(): int.