AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ASqlDatabase Class Reference

Public Member Functions#

_< ASqlQueryResultquery (const AString &query, const AVector< AVariant > &params={})
 Execute a query with the result (SELECT).
 
int execute (const AString &query, const AVector< AVariant > &params={})
 Execute a query with no result (UPDATE, INSERT, DELETE, etc.)
 
SqlDriverType getDriverType ()
 the type of the driver. Required to correct queries in the database due to driver differences.
 

Static Public Member Functions#

static _< ASqlDatabaseconnect (const AString &driverName, const AString &address, uint16_t port=0, const AString &databaseName={}, const AString &username={}, const AString &password={})
 Connect to the database using the specified details and driver.
 
static void registerDriver (_< ISqlDriver > driver)
 

Member Function Documentation#

◆ connect()#

static _< ASqlDatabase > ASqlDatabase::connect ( const AString & driverName,
const AString & address,
uint16_t port = 0,
const AString & databaseName = {},
const AString & username = {},
const AString & password = {} )
static
Parameters
driverNamename of the database driver. If the driver is not loaded, an attempt will be made to load the driver based on the template aui.DRIVERNAME (aui.DRIVERNAME.dll for Windows, libaui.DRIVERNAME.so for Linux, etc...). If the driver failed to load SQLException will be thrown.
addressserver host (IP address or domain)
portserver port
databaseNamename of the database
usernameuser name; optional in some DBMS
passworduser password; optional in some DBMS
Returns
object for communicating with the database; in some DBMS - optional
Exceptions
SQLExceptionwhen any error occurs

◆ execute()#

int ASqlDatabase::execute ( const AString & query,
const AVector< AVariant > & params = {} )
Parameters
querythe SQL query
paramsquery arguments
Returns
number of affected rows
Exceptions
SQLExceptionif any error occurs

◆ getDriverType()#

SqlDriverType ASqlDatabase::getDriverType ( )
Returns
type of driver

◆ query()#

_< ASqlQueryResult > ASqlDatabase::query ( const AString & query,
const AVector< AVariant > & params = {} )
Parameters
querythe SQL query
paramsquery arguments
Returns
query result
Exceptions
SQLExceptionwhen any error occurs