Changeset View
Changeset View
Standalone View
Standalone View
src/KDbConnection.h
Show All 14 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
15 | along with this program; see the file COPYING. If not, write to | 15 | along with this program; see the file COPYING. If not, write to | ||
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_CONNECTION_H | 20 | #ifndef KDB_CONNECTION_H | ||
21 | #define KDB_CONNECTION_H | 21 | #define KDB_CONNECTION_H | ||
22 | 22 | | |||
23 | #include "KDbCursor.h" | ||||
23 | #include "KDbDriver.h" | 24 | #include "KDbDriver.h" | ||
24 | #include "KDbPreparedStatement.h" | 25 | #include "KDbPreparedStatement.h" | ||
25 | #include "KDbTableSchema.h" | 26 | #include "KDbTableSchema.h" | ||
26 | #include "KDbTransaction.h" | 27 | #include "KDbTransaction.h" | ||
27 | #include "KDbTristate.h" | 28 | #include "KDbTristate.h" | ||
28 | 29 | | |||
29 | class KDbConnectionPrivate; | 30 | class KDbConnectionPrivate; | ||
30 | class KDbConnectionData; | 31 | class KDbConnectionData; | ||
31 | class KDbConnectionOptions; | 32 | class KDbConnectionOptions; | ||
32 | class KDbConnectionProxy; | 33 | class KDbConnectionProxy; | ||
33 | class KDbCursor; | | |||
34 | class KDbDriver; | 34 | class KDbDriver; | ||
35 | class KDbProperties; | 35 | class KDbProperties; | ||
36 | class KDbRecordData; | 36 | class KDbRecordData; | ||
37 | class KDbRecordEditBuffer; | 37 | class KDbRecordEditBuffer; | ||
38 | class KDbServerVersionInfo; | 38 | class KDbServerVersionInfo; | ||
39 | class KDbSqlResult; | 39 | class KDbSqlResult; | ||
40 | class KDbTableSchemaChangeListener; | 40 | class KDbTableSchemaChangeListener; | ||
41 | class KDbVersionInfo; | 41 | class KDbVersionInfo; | ||
▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Line(s) | 52 | public: | |||
358 | not just isEmpty(). | 358 | not just isEmpty(). | ||
359 | */ | 359 | */ | ||
360 | virtual KDbEscapedString escapeString(const QString& str) const; | 360 | virtual KDbEscapedString escapeString(const QString& str) const; | ||
361 | 361 | | |||
362 | /*! Prepares SELECT query described by a raw statement @a sql. | 362 | /*! Prepares SELECT query described by a raw statement @a sql. | ||
363 | @return opened cursor created for results of this query | 363 | @return opened cursor created for results of this query | ||
364 | or @c nullptr if there was any error. Ownership of the returned object is passed | 364 | or @c nullptr if there was any error. Ownership of the returned object is passed | ||
365 | to the caller. | 365 | to the caller. | ||
366 | KDbCursor can have optionally applied @a cursor_options (one of more selected from KDbCursor::Options). | 366 | KDbCursor can have optionally applied @a options (one of more selected from KDbCursor::Options). | ||
367 | Preparation means that returned cursor is created but not opened. | 367 | Preparation means that returned cursor is created but not opened. | ||
368 | Open this when you would like to do it with KDbCursor::open(). | 368 | Open this when you would like to do it with KDbCursor::open(). | ||
369 | 369 | | |||
370 | Note for driver developers: you should initialize cursor engine-specific | 370 | Note for driver developers: you should initialize cursor engine-specific | ||
371 | resources and return KDbCursor subclass' object | 371 | resources and return KDbCursor subclass' object | ||
372 | (passing @a sql and @a cursor_options to its constructor). | 372 | (passing @a sql and @a options to its constructor). | ||
373 | */ | 373 | */ | ||
374 | virtual KDbCursor* prepareQuery(const KDbEscapedString& sql, int cursor_options = 0) Q_REQUIRED_RESULT = 0; | 374 | virtual KDbCursor* prepareQuery(const KDbEscapedString& sql, | ||
375 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT = 0; | ||||
375 | 376 | | |||
376 | /*! @overload prepareQuery(const KDbEscapedString&, int) | 377 | /*! @overload | ||
377 | Prepares query described by @a query schema. @a params are values of parameters that | 378 | Prepares query described by @a query schema. @a params are values of parameters that | ||
378 | will be inserted into places marked with [] before execution of the query. | 379 | will be inserted into places marked with [] before execution of the query. | ||
379 | 380 | | |||
380 | Note for driver developers: you should initialize cursor engine-specific | 381 | Note for driver developers: you should initialize cursor engine-specific | ||
381 | resources and return KDbCursor subclass' object | 382 | resources and return KDbCursor subclass' object | ||
382 | (passing @a query and @a cursor_options to it's constructor). | 383 | (passing @a query and @a options to it's constructor). | ||
383 | Kexi SQL and driver-specific escaping is performed on table names. | 384 | Kexi SQL and driver-specific escaping is performed on table names. | ||
384 | */ | 385 | */ | ||
385 | KDbCursor* prepareQuery(KDbQuerySchema* query, const QList<QVariant>& params, | 386 | KDbCursor* prepareQuery(KDbQuerySchema* query, const QList<QVariant>& params, | ||
386 | int cursor_options = 0) Q_REQUIRED_RESULT; | 387 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||
387 | 388 | | |||
388 | /*! @overload prepareQuery(KDbQuerySchema* query, const QList<QVariant>& params, | 389 | /*! @overload | ||
389 | int cursor_options = 0 ) | | |||
390 | Prepares query described by @a query schema without parameters. | 390 | Prepares query described by @a query schema without parameters. | ||
391 | */ | 391 | */ | ||
392 | virtual KDbCursor* prepareQuery(KDbQuerySchema* query, int cursor_options = 0) Q_REQUIRED_RESULT = 0; | 392 | virtual KDbCursor* prepareQuery(KDbQuerySchema* query, | ||
393 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT = 0; | ||||
393 | 394 | | |||
394 | /*! @overload prepareQuery(const KDbEscapedString&, int) | 395 | /*! @overload | ||
395 | Statement is build from data provided by @a table schema, | 396 | Statement is build from data provided by @a table schema, it is like "select * from table_name".*/ | ||
396 | it is like "select * from table_name".*/ | 397 | KDbCursor* prepareQuery(KDbTableSchema* table, | ||
397 | KDbCursor* prepareQuery(KDbTableSchema* table, int cursor_options = 0) Q_REQUIRED_RESULT; | 398 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||
398 | 399 | | |||
399 | /*! Executes SELECT query described by a raw SQL statement @a sql. | 400 | /*! Executes SELECT query described by a raw SQL statement @a sql. | ||
400 | @return opened cursor created for results of this query | 401 | @return opened cursor created for results of this query | ||
401 | or 0 if there was any error on the cursor creation or opening. | 402 | or 0 if there was any error on the cursor creation or opening. | ||
402 | Ownership of the returned object is passed to the caller. | 403 | Ownership of the returned object is passed to the caller. | ||
403 | KDbCursor can have optionally applied @a cursor_options | 404 | KDbCursor can have optionally applied @a options. | ||
404 | (one of more selected from KDbCursor::Options). | | |||
405 | Identifiers in @a sql that are the same as keywords | 405 | Identifiers in @a sql that are the same as keywords | ||
406 | in KDbSQL dialect or the backend's SQL have to be escaped. | 406 | in KDbSQL dialect or the backend's SQL have to be escaped. | ||
407 | */ | 407 | */ | ||
408 | KDbCursor* executeQuery(const KDbEscapedString& sql, int cursor_options = 0) Q_REQUIRED_RESULT; | 408 | KDbCursor* executeQuery(const KDbEscapedString& sql, | ||
409 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||||
409 | 410 | | |||
410 | /*! @overload executeQuery(const KDbEscapedString&, int) | 411 | /*! @overload executeQuery(const KDbEscapedString&, int) | ||
411 | @a params are values of parameters that | 412 | @a params are values of parameters that | ||
412 | will be inserted into places marked with [] before execution of the query. | 413 | will be inserted into places marked with [] before execution of the query. | ||
413 | 414 | | |||
414 | Statement is build from data provided by @a query schema. | 415 | Statement is build from data provided by @a query schema. | ||
415 | Kexi SQL and driver-specific escaping is performed on table names. */ | 416 | Kexi SQL and driver-specific escaping is performed on table names. */ | ||
416 | KDbCursor* executeQuery(KDbQuerySchema* query, const QList<QVariant>& params, | 417 | KDbCursor* executeQuery(KDbQuerySchema* query, const QList<QVariant>& params, | ||
417 | int cursor_options = 0) Q_REQUIRED_RESULT; | 418 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||
418 | 419 | | |||
419 | /*! @overload executeQuery(KDbQuerySchema* query, const QList<QVariant>& params, | 420 | /*! @overload */ | ||
420 | int cursor_options = 0 ) */ | 421 | KDbCursor* executeQuery(KDbQuerySchema* query, | ||
421 | KDbCursor* executeQuery(KDbQuerySchema* query, int cursor_options = 0) Q_REQUIRED_RESULT; | 422 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||
422 | 423 | | |||
423 | /*! @overload executeQuery(const KDbEscapedString&, int) | 424 | /*! @overload | ||
424 | Executes query described by @a query schema without parameters. | 425 | Executes query described by @a query schema without parameters. | ||
425 | Statement is build from data provided by @a table schema, | 426 | Statement is build from data provided by @a table schema, | ||
426 | it is like "select * from table_name".*/ | 427 | it is like "select * from table_name".*/ | ||
427 | KDbCursor* executeQuery(KDbTableSchema* table, int cursor_options = 0) Q_REQUIRED_RESULT; | 428 | KDbCursor* executeQuery(KDbTableSchema* table, | ||
429 | KDbCursor::Options options = KDbCursor::Option::None) Q_REQUIRED_RESULT; | ||||
428 | 430 | | |||
429 | /*! Deletes cursor @a cursor previously created by functions like executeQuery() | 431 | /*! Deletes cursor @a cursor previously created by functions like executeQuery() | ||
430 | for this connection. | 432 | for this connection. | ||
431 | There is an attempt to close the cursor with KDbCursor::close() if it was opened. | 433 | There is an attempt to close the cursor with KDbCursor::close() if it was opened. | ||
432 | Anyway, at last cursor is deleted. | 434 | Anyway, at last cursor is deleted. | ||
433 | @return true if cursor is properly closed before deletion. */ | 435 | @return true if cursor is properly closed before deletion. */ | ||
434 | bool deleteCursor(KDbCursor *cursor); | 436 | bool deleteCursor(KDbCursor *cursor); | ||
435 | 437 | | |||
▲ Show 20 Lines • Show All 849 Lines • Show Last 20 Lines |