Changeset View
Changeset View
Standalone View
Standalone View
src/sql/KDbSqlResult.h
Show All 15 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef KDB_SQLRESULT_H | 20 | #ifndef KDB_SQLRESULT_H | ||
21 | #define KDB_SQLRESULT_H | 21 | #define KDB_SQLRESULT_H | ||
22 | 22 | | |||
23 | #include "kdb_export.h" | 23 | #include "kdb_export.h" | ||
24 | #include <QSharedPointer> | ||||
24 | #include <QString> | 25 | #include <QString> | ||
25 | 26 | | |||
26 | class KDbConnection; | 27 | class KDbConnection; | ||
27 | class KDbField; | 28 | class KDbField; | ||
28 | class KDbRecordData; | 29 | class KDbRecordData; | ||
29 | class KDbResult; | 30 | class KDbResult; | ||
30 | class KDbSqlField; | 31 | class KDbSqlField; | ||
31 | class KDbSqlRecord; | 32 | class KDbSqlRecord; | ||
32 | 33 | | |||
33 | //! The KDbSqlResult class abstracts result of execution of raw SQL query executed using KDbConnection::executeSQL() | | |||
34 | /** | 34 | /** | ||
35 | * KDbSqlResult allows to return low-level information about fields of the result | 35 | * The KDbSqlResult class abstracts result of a raw SQL query preparation by KDbConnection::prepareSql() | ||
36 | * and fetch records. | 36 | * | ||
37 | * The KDbSqlResult object provides low-level access to information about fields of the result and | ||||
38 | * can fetch records by actual execution of the prepared query. | ||||
39 | * | ||||
40 | * @note the KDbSqlResult object should be deleted before closing the database connection that | ||||
41 | * created it. This is needed because the connection is used by the object to retrieve data or to | ||||
42 | * obtain status information. | ||||
37 | */ | 43 | */ | ||
38 | class KDB_EXPORT KDbSqlResult | 44 | class KDB_EXPORT KDbSqlResult | ||
39 | { | 45 | { | ||
40 | public: | 46 | public: | ||
41 | KDbSqlResult(); | 47 | KDbSqlResult(); | ||
42 | 48 | | |||
43 | virtual ~KDbSqlResult(); | 49 | virtual ~KDbSqlResult(); | ||
44 | 50 | | |||
45 | //! @return connection for this result | 51 | //! @return connection for this result | ||
46 | virtual KDbConnection *connection() const { return nullptr; } | 52 | virtual KDbConnection *connection() const { return nullptr; } | ||
47 | 53 | | |||
48 | //! @return number of fields in this result | 54 | //! @return number of fields in this result | ||
49 | virtual int fieldsCount() = 0; | 55 | virtual int fieldsCount() = 0; | ||
50 | 56 | | |||
51 | //! @return field @a index from this result | 57 | //! @return field @a index from this result | ||
52 | virtual KDbSqlField *field(int index) Q_REQUIRED_RESULT = 0; | 58 | virtual KDbSqlField *field(int index) Q_REQUIRED_RESULT = 0; | ||
53 | 59 | | |||
54 | //! Creates a KDb field for field @a index and returns it | 60 | //! Creates a KDb field for field @a index and returns it | ||
55 | //! On failure returns @c nullptr. | 61 | //! On failure returns @c nullptr. | ||
56 | //! @a tableName is the table name and may be used to retrieve information but may | 62 | //! @a tableName is the table name and may be used to retrieve information but may | ||
57 | //! be ignored as well if the KDbSqlResult already has field metadata available. | 63 | //! be ignored as well if the KDbSqlResult already has field metadata available. | ||
58 | virtual KDbField* createField(const QString &tableName, int index) Q_REQUIRED_RESULT = 0; | 64 | virtual KDbField* createField(const QString &tableName, int index) Q_REQUIRED_RESULT = 0; | ||
59 | 65 | | |||
60 | //! Fetches one record and returns it. @return nullptr if there is no record to fetch or on error. | 66 | /** | ||
61 | //! Check lastResult() for errors. | 67 | * Fetches one record. | ||
62 | virtual KDbSqlRecord* fetchRecord() Q_REQUIRED_RESULT = 0; | 68 | * | ||
69 | * @return a shared pointer to the record or a null pointer if there is no record to fetch or | ||||
70 | * on error. | ||||
71 | * Check lastResult() for detailed result. Ownership is transferred to the caller. | ||||
72 | */ | ||||
73 | virtual QSharedPointer<KDbSqlRecord> fetchRecord() Q_REQUIRED_RESULT = 0; | ||||
63 | 74 | | |||
64 | //! Convenience method. Fetches one record and all values into @a data. | 75 | //! Convenience method. Fetches one record and all values into @a data. | ||
65 | //! @return record data object and passes its ownership | 76 | //! @return record data object and passes its ownership | ||
66 | //! @c nullptr is returned on error or when there is no record to fetch. | 77 | //! @c nullptr is returned on error or when there is no record to fetch. | ||
67 | //! Check lastResult() for errors. | 78 | //! Check lastResult() for errors. | ||
68 | KDbRecordData* fetchRecordData() Q_REQUIRED_RESULT; | 79 | KDbRecordData* fetchRecordData() Q_REQUIRED_RESULT; | ||
69 | 80 | | |||
70 | //! @return result of last operation on this SQL result | 81 | //! @return result of last operation on this SQL result | ||
Show All 12 Lines |