Changeset View
Changeset View
Standalone View
Standalone View
src/KDbConnection.h
Show First 20 Lines • Show All 892 Lines • ▼ Show 20 Line(s) | 692 | //! @todo (js): update any structure (e.g. query) that depend on this table! | |||
---|---|---|---|---|---|
893 | bool removeDataBlock(int objectID, const QString& dataID = QString()); | 893 | bool removeDataBlock(int objectID, const QString& dataID = QString()); | ||
894 | 894 | | |||
895 | /*! Prepare an SQL statement and return a @a KDbPreparedStatement instance. */ | 895 | /*! Prepare an SQL statement and return a @a KDbPreparedStatement instance. */ | ||
896 | KDbPreparedStatement prepareStatement(KDbPreparedStatement::Type type, | 896 | KDbPreparedStatement prepareStatement(KDbPreparedStatement::Type type, | ||
897 | KDbFieldList* fields, const QStringList& whereFieldNames = QStringList()); | 897 | KDbFieldList* fields, const QStringList& whereFieldNames = QStringList()); | ||
898 | 898 | | |||
899 | bool isInternalTableSchema(const QString& tableName); | 899 | bool isInternalTableSchema(const QString& tableName); | ||
900 | 900 | | |||
901 | /** | ||||
902 | * @brief Returns number of records returned by given SQL statement | ||||
903 | * | ||||
904 | * @return number of records that can be retrieved after executing @a sql statement within | ||||
905 | * a connection @a conn. The statement should be of type SELECT. For SQL data sources it does not | ||||
906 | * fetch any records, only "COUNT(*)" SQL aggregation is used at the backed. | ||||
907 | * -1 is returned if any error occurred or if @a conn is @c nullptr. | ||||
908 | * | ||||
909 | * @since 3.1 | ||||
910 | */ | ||||
911 | //! @todo perhaps use quint64 here? | ||||
912 | KDB_EXPORT int recordCount(const KDbEscapedString& sql); | ||||
913 | | ||||
914 | /** | ||||
915 | * @brief Returns number of records that contains given table | ||||
916 | * | ||||
917 | * @return number of records that can be retrieved from @a tableSchema. | ||||
918 | * To obtain the result the table must be created or retrieved using a KDbConnection object, | ||||
919 | * i.e. tableSchema.connection() must not return @c nullptr. For SQL data sources only "COUNT(*)" | ||||
920 | * SQL aggregation is used at the backed. | ||||
921 | * -1 is returned if error occurred or if tableSchema.connection() is @c nullptr. | ||||
922 | * | ||||
923 | * @since 3.1 | ||||
924 | */ | ||||
925 | //! @todo perhaps use quint64 here? | ||||
926 | //! @todo does not work with non-SQL data sources | ||||
927 | KDB_EXPORT int recordCount(const KDbTableSchema& tableSchema); | ||||
928 | | ||||
929 | /** | ||||
930 | * @overload | ||||
931 | * | ||||
932 | * Operates on a query schema. @a params are optional values of parameters that will be inserted | ||||
933 | * into [] placeholders before execution of query that counts the records. | ||||
934 | * To obtain the result the query must be created or retrieved using a KDbConnection object, | ||||
935 | * i.e. querySchema->connection() must not return @c nullptr. For SQL data sources only "COUNT(*)" | ||||
936 | * SQL aggregation is used at the backed. | ||||
937 | * -1 is returned if error occurred or if querySchema->connection() is @c nullptr. | ||||
938 | * | ||||
939 | * @since 3.1 | ||||
940 | */ | ||||
941 | //! @todo perhaps use quint64 here? | ||||
942 | KDB_EXPORT int recordCount(KDbQuerySchema* querySchema, | ||||
943 | const QList<QVariant>& params = QList<QVariant>()); | ||||
944 | | ||||
945 | /** | ||||
946 | * @overload | ||||
947 | * | ||||
948 | * Operates on a table or query schema. @a params is a list of optional parameters that | ||||
949 | * will be inserted into [] placeholders before execution of query that counts the records. | ||||
950 | * | ||||
951 | * If @a tableOrQuery is @c nullptr or provides neither table nor query, -1 is returned. | ||||
952 | * | ||||
953 | * @since 3.1 | ||||
954 | */ | ||||
955 | //! @todo perhaps use quint64 here? | ||||
956 | KDB_EXPORT int recordCount(KDbTableOrQuerySchema* tableOrQuery, | ||||
957 | const QList<QVariant>& params = QList<QVariant>()); | ||||
958 | | ||||
901 | //! Identifier escaping function in the associated KDbDriver. | 959 | //! Identifier escaping function in the associated KDbDriver. | ||
902 | /*! Calls the identifier escaping function in this connection to | 960 | /*! Calls the identifier escaping function in this connection to | ||
903 | escape table and column names. This should be used when explicitly | 961 | escape table and column names. This should be used when explicitly | ||
904 | constructing SQL strings (e.g. "FROM " + escapeIdentifier(tablename)). | 962 | constructing SQL strings (e.g. "FROM " + escapeIdentifier(tablename)). | ||
905 | It should not be used for other functions (e.g. don't do | 963 | It should not be used for other functions (e.g. don't do | ||
906 | useDatabase(escapeIdentifier(database))), because the identifier will | 964 | useDatabase(escapeIdentifier(database))), because the identifier will | ||
907 | be escaped when the called function generates, for example, "USE " + | 965 | be escaped when the called function generates, for example, "USE " + | ||
908 | escapeIdentifier(database). | 966 | escapeIdentifier(database). | ||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Line(s) | 977 | protected: | |||
1247 | bool deleteRecord(KDbQuerySchema* query, KDbRecordData* data, bool useRecordId = false); | 1305 | bool deleteRecord(KDbQuerySchema* query, KDbRecordData* data, bool useRecordId = false); | ||
1248 | /*! Delete all existing records. */ | 1306 | /*! Delete all existing records. */ | ||
1249 | bool deleteAllRecords(KDbQuerySchema* query); | 1307 | bool deleteAllRecords(KDbQuerySchema* query); | ||
1250 | 1308 | | |||
1251 | /*! Called by KDbTableSchema -- signals destruction to KDbConnection object | 1309 | /*! Called by KDbTableSchema -- signals destruction to KDbConnection object | ||
1252 | To avoid having deleted table object on its list. */ | 1310 | To avoid having deleted table object on its list. */ | ||
1253 | void removeMe(KDbTableSchema *ts); | 1311 | void removeMe(KDbTableSchema *ts); | ||
1254 | 1312 | | |||
1313 | // -- internal methods follow | ||||
1314 | | ||||
1255 | /*! @internal | 1315 | /*! @internal | ||
1256 | @return true if the cursor @a cursor contains column @a column, | 1316 | @return true if the cursor @a cursor contains column @a column, | ||
1257 | else, sets appropriate error with a message and returns false. */ | 1317 | else, sets appropriate error with a message and returns false. */ | ||
1258 | bool checkIfColumnExists(KDbCursor *cursor, int column); | 1318 | bool checkIfColumnExists(KDbCursor *cursor, int column); | ||
1259 | 1319 | | |||
1260 | /*! @internal used by insertRecord() methods. */ | 1320 | /*! @internal used by insertRecord() methods. */ | ||
1261 | QSharedPointer<KDbSqlResult> insertRecordInternal(const QString &tableSchemaName, | 1321 | QSharedPointer<KDbSqlResult> insertRecordInternal(const QString &tableSchemaName, | ||
1262 | KDbFieldList *fields, | 1322 | KDbFieldList *fields, | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 1391 | private: | |||
1341 | 1401 | | |||
1342 | Q_DISABLE_COPY(KDbConnection) | 1402 | Q_DISABLE_COPY(KDbConnection) | ||
1343 | friend class KDbConnectionPrivate; | 1403 | friend class KDbConnectionPrivate; | ||
1344 | friend class KDbAlterTableHandler; | 1404 | friend class KDbAlterTableHandler; | ||
1345 | friend class KDbConnectionProxy; | 1405 | friend class KDbConnectionProxy; | ||
1346 | friend class KDbCursor; | 1406 | friend class KDbCursor; | ||
1347 | friend class KDbDriver; | 1407 | friend class KDbDriver; | ||
1348 | friend class KDbProperties; //!< for setError() | 1408 | friend class KDbProperties; //!< for setError() | ||
1409 | friend class KDbQuerySchema; | ||||
1410 | friend class KDbQuerySchemaPrivate; | ||||
1349 | friend class KDbTableSchemaChangeListener; | 1411 | friend class KDbTableSchemaChangeListener; | ||
1350 | friend class KDbTableSchema; //!< for removeMe() | 1412 | friend class KDbTableSchema; //!< for removeMe() | ||
1351 | }; | 1413 | }; | ||
1352 | 1414 | | |||
1353 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::QueryRecordOptions) | 1415 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::QueryRecordOptions) | ||
1354 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::AlterTableNameOptions) | 1416 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::AlterTableNameOptions) | ||
1355 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::CreateTableOptions) | 1417 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDbConnection::CreateTableOptions) | ||
1356 | 1418 | | |||
1357 | #endif | 1419 | #endif |