DUNE: Uniform Navigational Environment  2019.02.0
DUNE::Database::Connection Class Reference

Detailed Description

Database connection.

Public Types

enum  ConnectionFlags { CF_RDONLY, CF_CREATE }
 

Public Member Functions

 Connection (int flags)
 
 Connection (const char *path, int flags)
 
 ~Connection (void)
 
void execute (const char *sql_stmt, int *count=0)
 
void beginTransaction (void)
 
void commit (void)
 
void rollback (void)
 
const char * lastError (void)
 
DB_HANDLEhandle (void)
 

Member Enumeration Documentation

Connection flags.

Enumerator
CF_RDONLY 

Open read-only connection.

CF_CREATE 

Create database if it does not exist.

Constructor & Destructor Documentation

DUNE::Database::Connection::Connection ( int  flags)

Constructs a memory-only database.

Parameters
flagsconnection flags (
See Also
ConnectionFlags)
DUNE::Database::Connection::Connection ( const char *  path,
int  flags 
)

Constructs a file-based database.

Parameters
pathdatabase file
flagsconnection flags (
See Also
ConnectionFlags)
DUNE::Database::Connection::~Connection ( void  )

Destructor.

Member Function Documentation

void DUNE::Database::Connection::beginTransaction ( void  )

Begin transaction.

References DUNE::Database::Statement::execute().

void DUNE::Database::Connection::commit ( void  )

Commit (end) current transaction.

References DUNE::Database::Statement::execute().

void DUNE::Database::Connection::execute ( const char *  sql_stmt,
int *  count = 0 
)

Execute an SQL statement directly and optionally obtain the number of affected rows for (INSERT, UPDATE, and DELETE statements).

Parameters
sql_stmtSQL statement
countoptional argument to get number of affected rows
DB_HANDLE* DUNE::Database::Connection::handle ( void  )
inline

Get internal database connection handle.

This is for use by other classes in the package.

Referenced by DUNE::Database::Statement::execute(), and DUNE::Database::Statement::Statement().

const char * DUNE::Database::Connection::lastError ( void  )

Get description of last error.

Returns
description of last database error.
void DUNE::Database::Connection::rollback ( void  )

Rollback current transaction.

References DUNE::Database::Statement::execute().

Collaboration diagram for DUNE::Database::Connection:
Collaboration graph