Changeset View
Changeset View
Standalone View
Standalone View
src/KDb.h
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | |||||
107 | KDB_EXPORT bool deleteAllRecords(KDbConnection* conn, const QString &tableName); | 107 | KDB_EXPORT bool deleteAllRecords(KDbConnection* conn, const QString &tableName); | ||
108 | 108 | | |||
109 | //! @overload bool deleteAllRecords(KDbConnection*, const QString&); | 109 | //! @overload bool deleteAllRecords(KDbConnection*, const QString&); | ||
110 | inline bool deleteAllRecords(KDbConnection* conn, const KDbTableSchema &table) | 110 | inline bool deleteAllRecords(KDbConnection* conn, const KDbTableSchema &table) | ||
111 | { | 111 | { | ||
112 | return KDb::deleteAllRecords(conn, table.name()); | 112 | return KDb::deleteAllRecords(conn, table.name()); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | /*! @return autoincrement field's @a autoIncrementFieldName value | 115 | /** | ||
116 | of last inserted record for result @a result. | 116 | * Returns value of last inserted record for an autoincrement field | ||
117 | 117 | * | |||
118 | Simply, method internally fetches values of the last inserted record and returns selected | 118 | * This method internally fetches values of the last inserted record for which @a result was | ||
119 | field's value. The field belong to @a tableName table. | 119 | * returned and returns selected field's value. The field belong to @a tableName table. | ||
120 | Requirements: the field must be of integer type, there must be a record inserted using query | 120 | * The field must be of integer type, there must be a record inserted using query for which the @a | ||
121 | for which the @a result is returned. | 121 | * result is returned. | ||
122 | On error std::numeric_limits<quint64>::max() is returned. | 122 | * std::numeric_limits<quint64>::max() is returned on error or if @a result is null. | ||
123 | Last inserted record is identified by a magical record identifier, usually called ROWID | 123 | * The last inserted record is identified by a magical record identifier, usually called ROWID | ||
124 | (PostgreSQL has it as well as SQLite; see KDbDriverBehavior::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE). | 124 | * (PostgreSQL has it as well as SQLite; | ||
125 | ROWID's value will be assigned back to @a recordId if this pointer is not null. | 125 | * see KDbDriverBehavior::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE). | ||
126 | * ROWID's value will be assigned back to @a recordId if this pointer is not @c nullptr. | ||||
126 | */ | 127 | */ | ||
127 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbSqlResult *result, | 128 | KDB_EXPORT quint64 lastInsertedAutoIncValue(QSharedPointer<KDbSqlResult> result, | ||
128 | const QString& autoIncrementFieldName, const QString& tableName, quint64* recordId = nullptr); | 129 | const QString &autoIncrementFieldName, | ||
130 | const QString &tableName, quint64 *recordId = nullptr); | ||||
anthonyfieroni: Shared pointer make sense when it's passed by value to increase ref count. | |||||
staniek: Thanks Anthony, definitely that was too mechanical change.
| |||||
Done, the param is now optional. Feel free to review the other code :) staniek: Done, the param is now optional. Feel free to review the other code :) | |||||
129 | 131 | | |||
130 | /*! @overload int lastInsertedAutoIncValue(KDbSqlResult *, const QString&, const QString&, quint64*) | 132 | /** | ||
133 | * @overload | ||||
134 | * | ||||
131 | * Accepts @a recordId that can be obtained from KDbPreparedStatement::lastInsertRecordId() | 135 | * Accepts @a recordId that can be obtained from KDbPreparedStatement::lastInsertRecordId() | ||
132 | * or KDbSqlResult::lastInsertRecordId(). | 136 | * or KDbSqlResult::lastInsertRecordId(). | ||
133 | */ | 137 | */ | ||
134 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbConnection *conn, const quint64 recordId, | 138 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbConnection *conn, const quint64 recordId, | ||
135 | const QString& autoIncrementFieldName, const QString& tableName); | 139 | const QString &autoIncrementFieldName, | ||
140 | const QString &tableName); | ||||
136 | 141 | | |||
137 | /*! @overload int lastInsertedAutoIncValue(KDbSqlResult *, const QString&, const QString&, quint64*) | 142 | /** | ||
143 | @overload | ||||
138 | */ | 144 | */ | ||
139 | inline quint64 lastInsertedAutoIncValue(KDbSqlResult *result, | 145 | inline quint64 lastInsertedAutoIncValue(QSharedPointer<KDbSqlResult> result, | ||
140 | const QString& autoIncrementFieldName, const KDbTableSchema& table, quint64* recordId = nullptr) | 146 | const QString &autoIncrementFieldName, | ||
147 | const KDbTableSchema &table, quint64 *recordId = nullptr) | ||||
141 | { | 148 | { | ||
142 | return lastInsertedAutoIncValue(result, autoIncrementFieldName, table.name(), recordId); | 149 | return lastInsertedAutoIncValue(result, autoIncrementFieldName, table.name(), recordId); | ||
143 | } | 150 | } | ||
144 | 151 | | |||
145 | /*! @return list of field types for field type group @a typeGroup. */ | 152 | /*! @return list of field types for field type group @a typeGroup. */ | ||
146 | KDB_EXPORT const QList<KDbField::Type> fieldTypesForGroup(KDbField::TypeGroup typeGroup); | 153 | KDB_EXPORT const QList<KDbField::Type> fieldTypesForGroup(KDbField::TypeGroup typeGroup); | ||
147 | 154 | | |||
148 | /*! @return list of translated field type names for field type group @a typeGroup. */ | 155 | /*! @return list of translated field type names for field type group @a typeGroup. */ | ||
▲ Show 20 Lines • Show All 584 Lines • Show Last 20 Lines |
Shared pointer make sense when it's passed by value to increase ref count.