libdballe
6.8
|
Database connection. More...
#include <internals.h>
Public Member Functions | |
void | connect (const char *dsn, const char *user, const char *password) |
void | connect_file (const std::string &fname) |
void | driver_connect (const char *config) |
std::string | driver_name () |
std::string | driver_version () |
void | get_info (SQLUSMALLINT info_type, SQLINTEGER &res) |
void | set_autocommit (bool val) |
void | commit () |
Commit a transaction. | |
void | rollback () |
Rollback a transaction. | |
bool | has_table (const std::string &name) |
Check if the database contains a table. | |
std::string | get_setting (const std::string &key) |
Get a value from the settings table. More... | |
void | set_setting (const std::string &key, const std::string &value) |
Set a value in the settings table. More... | |
void | drop_settings () |
Drop the settings table. | |
void | drop_table_if_exists (const char *name) |
Delete a table in the database if it exists, otherwise do nothing. | |
void | drop_sequence_if_exists (const char *name) |
Delete a sequence in the database if it exists, otherwise do nothing. | |
int | get_last_insert_id () |
Return LAST_INSERT_ID or LAST_INSER_ROWID or whatever is appropriate for the current database, if supported. More... | |
Data Fields | |
SQLHDBC | od_conn |
ODBC database connection. | |
bool | connected |
True if the connection is open. | |
enum ServerType | server_type |
Type of SQL server we are connected to. | |
unsigned | server_quirks |
Bitfield of quirks we should be aware of when using ODBC. | |
Protected Member Functions | |
void | init_after_connect () |
Protected Attributes | |
db::Statement * | stm_last_insert_id |
Precompiled LAST_INSERT_ID (or equivalent) SQL statement. | |
DBALLE_SQL_C_SINT_TYPE | m_last_insert_id |
ID of the last autogenerated primary key. | |
Database connection.
int dballe::db::Connection::get_last_insert_id | ( | ) |
Return LAST_INSERT_ID or LAST_INSER_ROWID or whatever is appropriate for the current database, if supported.
If not supported, an exception is thrown.
std::string dballe::db::Connection::get_setting | ( | const std::string & | key | ) |
Get a value from the settings table.
Returns the empty string if the table does not exist.
void dballe::db::Connection::set_setting | ( | const std::string & | key, |
const std::string & | value | ||
) |
Set a value in the settings table.
The table is created if it does not exist.