Public Member Functions | |
Database () | |
Create new database object. | |
Database (const wxString &coninfo) | |
Creates new object and initializes it with specified connection info. | |
virtual | ~Database () |
Destroys object. | |
void | connection_info (const wxString &coninfo) |
Sets connection info for this object. | |
const wxString & | connection_info () const |
Return current connection info. | |
bool | connect (bool connect=true) |
Connect to or disconnect from database. | |
bool | connected () const |
Is this object connected to database. | |
PGconn * | handle () |
Return connection handle. | |
void | attach (DB_client *cli, int level) |
Attach new client to this connection. | |
void | detach (DB_client *cli, int level) |
Detach client. | |
void | detach_all (int level) |
Detach all clients. | |
bool | begin_transaction () |
Begin new transaction. | |
bool | enter_transaction () |
Ensure, that database is in transaction. | |
bool | commit () |
Commit current transaction. | |
void | rollback () |
Rollbacks current transaction. | |
bool | in_transaction () |
Is database in transaction. | |
bool | run (const wxString &sql) |
Run SQL statement. | |
bool | run (Cached_result &result, const wxString &sql) |
Run SQL query. | |
const wxString & | last_err () const |
Get last error. | |
virtual void | sql_monitor (const wxString &sql) |
Monitor SQL for this database object. | |
const wxString | char_to_str (const char *s) const |
Convert C-string to wxString. | |
Static Public Attributes | |
static const int | ATTACH_CONNECTION = 10 |
Attach DB_client to connection. | |
static const int | ATTACH_TRANSACTION = 20 |
Attach DB_client to transaction. | |
Friends | |
class | wxPg::Query |
Classes | |
struct | client_ |
wxPg::Database::Database | ( | ) |
Create new database object.
Call connection_info() to complete initialization.
wxPg::Database::Database | ( | const wxString & | coninfo | ) | [explicit] |
Creates new object and initializes it with specified connection info.
coninfo | - see PQconnectdb() in PostgreSQL documentation for description. |
virtual wxPg::Database::~Database | ( | ) | [virtual] |
Destroys object.
void wxPg::Database::connection_info | ( | const wxString & | coninfo | ) |
Sets connection info for this object.
coninfo | - see PQconnectdb() in PostgreSQL documentation for description. |
const wxString& wxPg::Database::connection_info | ( | ) | const |
Return current connection info.
See PQconnectdb() in PostgreSQL documentation for returned string description.
bool wxPg::Database::connect | ( | bool | connect = true |
) |
Connect to or disconnect from database.
connect | - if is true, than connect, else - disconnect. |
bool wxPg::Database::connected | ( | ) | const |
Is this object connected to database.
PGconn* wxPg::Database::handle | ( | ) |
Return connection handle.
void wxPg::Database::attach | ( | DB_client * | cli, | |
int | level | |||
) |
Attach new client to this connection.
When database is disconnected or transaction is ended, detach() method is called for each client.
cli | - a client to attach. | |
level | - level of attach, use one of ATTACH_* constants. |
void wxPg::Database::detach | ( | DB_client * | cli, | |
int | level | |||
) |
void wxPg::Database::detach_all | ( | int | level | ) |
bool wxPg::Database::begin_transaction | ( | ) |
Begin new transaction.
If a transaction is already started, rollbacks old and starts new. Call last_err() to get error message.
bool wxPg::Database::enter_transaction | ( | ) |
Ensure, that database is in transaction.
If database is not in transaction, starts new transaction, simply returns true otherwise.
bool wxPg::Database::commit | ( | ) |
Commit current transaction.
If return value is false, call last_err() to get error message.
void wxPg::Database::rollback | ( | ) |
Rollbacks current transaction.
Does nothing if not in transaction.
bool wxPg::Database::in_transaction | ( | ) |
Is database in transaction.
bool wxPg::Database::run | ( | const wxString & | sql | ) |
Run SQL statement.
If returns false, call last_err() to get error message. Don't use it for SQL statements, that return data, as there is no way to get it.
sql | - SQL statement to execute. |
bool wxPg::Database::run | ( | Cached_result & | result, | |
const wxString & | sql | |||
) |
Run SQL query.
If returns false, call last_err() to get error message.
result | - Cached_result object, where result is stored. | |
sql | - SQL statement to execute. |
const wxString& wxPg::Database::last_err | ( | ) | const |
Get last error.
virtual void wxPg::Database::sql_monitor | ( | const wxString & | sql | ) | [virtual] |
Monitor SQL for this database object.
This method does nothing. Override it in derived class to get ability to monitor any SQL statement, executed by this object.
sql | - SQL statement, executed by this object. |
const wxString wxPg::Database::char_to_str | ( | const char * | s | ) | const |
Convert C-string to wxString.
Used internally for converting data, received from database, to wxString.
s | - zero terminated char array. |
const int wxPg::Database::ATTACH_CONNECTION = 10 [static] |
Attach DB_client to connection.
Client is detached when database is disconnected.
const int wxPg::Database::ATTACH_TRANSACTION = 20 [static] |
Attach DB_client to transaction.
Client is detached when transaction is committed or rollbacked.