123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- .TH "Db" 3 "Sun Dec 27 2020" "openPilotLog" \" -*- nroff -*-
- .ad l
- .nh
- .SH NAME
- Db \- The \fBDb\fP class provides a basic API for accessing the database programatically\&. It is used to set up the initial connection and various basic queries can be executed using a set of static functions\&. When interfacing with the database for the purpose of adding, deleting or updating entries, the use of the entry class and its subclasses is recommended\&. This clas is not supposed to be instantiated, if you need a database object, use QSqlDatabase::database('qt_sql_default_connection');\&.
- .SH SYNOPSIS
- .br
- .PP
- .PP
- \fC#include <db\&.h>\fP
- .SS "Public Types"
- .in +1c
- .ti -1c
- .RI "enum \fBeditRole\fP { \fBcreateNew\fP, \fBeditExisting\fP }"
- .br
- .RI "The editRole enum {createNew, editExisting} is used to differentiate between creating a new entry in the database vs editing an existing one\&. "
- .ti -1c
- .RI "enum \fBmatchType\fP { \fBexactMatch\fP, \fBpartialMatch\fP }"
- .br
- .RI "The matchType enum {exactMatch, partialMatch} is used to determine the matching when using a WHERE sql statement\&. exactMatch results in a '=' operator, whereas partiasMatch results in a 'LIKE' operator\&. "
- .in -1c
- .SS "Public Member Functions"
- .in +1c
- .ti -1c
- .RI "\fBDb\fP (\fBDb\fP const &)=delete"
- .br
- .ti -1c
- .RI "void \fBoperator=\fP (\fBDb\fP const &)=delete"
- .br
- .in -1c
- .SS "Static Public Member Functions"
- .in +1c
- .ti -1c
- .RI "static \fBDb\fP & \fBget\fP ()"
- .br
- .ti -1c
- .RI "static void \fBconnect\fP ()"
- .br
- .RI "connect establishes the database connection\&. Only needs to be called once within the application\&. Database is available thereafter, objects can be instantiated with QSqlDatabase::database('qt_sql_default_connection') as required\&. "
- .ti -1c
- .RI "static void \fBdisconnect\fP ()"
- .br
- .RI "disconnect Closes and removes the default database connection\&. "
- .ti -1c
- .RI "static QSqlDatabase \fBDatabase\fP ()"
- .br
- .RI "Can be used to access the database connection\&. "
- .ti -1c
- .RI "static bool \fBexists\fP (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
- .br
- .RI "\fBDb::exists\fP checks if a certain value exists in the database with a sqlite WHERE statement\&. "
- .ti -1c
- .RI "static bool \fBsingleUpdate\fP (QString table, QString column, QString value, QString checkColumn, QString checkvalue, \fBDb::matchType\fP match)"
- .br
- .RI "\fBDb::singleUpdate\fP Updates a single value in the database\&. Query format: UPDATE table SET column = value WHERE checkcolumn =/LIKE checkvalue\&. "
- .ti -1c
- .RI "static QString \fBsingleSelect\fP (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
- .br
- .RI "singleSelect Returns a single value from the database with a sqlite WHERE statement "
- .ti -1c
- .RI "static QVector< QString > \fBmultiSelect\fP (QVector< QString > columns, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
- .br
- .RI "\fBDb::multiSelect\fP Returns multiple values from the database with a sqlite WHERE statement\&. "
- .ti -1c
- .RI "static QVector< QString > \fBmultiSelect\fP (QVector< QString > columns, QString table)"
- .br
- .RI "\fBDb::multiSelect\fP Returns a complete column(s) for a given table\&. "
- .ti -1c
- .RI "static QVector< QString > \fBcustomQuery\fP (QString query, int returnValues)"
- .br
- .RI "\fBDb::customQuery\fP Can be used to send a complex query to the database\&. "
- .in -1c
- .SH "Detailed Description"
- .PP
- The \fBDb\fP class provides a basic API for accessing the database programatically\&. It is used to set up the initial connection and various basic queries can be executed using a set of static functions\&. When interfacing with the database for the purpose of adding, deleting or updating entries, the use of the entry class and its subclasses is recommended\&. This clas is not supposed to be instantiated, if you need a database object, use QSqlDatabase::database('qt_sql_default_connection');\&.
- .SH "Member Function Documentation"
- .PP
- .SS "static QVector<QString> Db::customQuery (QString query, int returnValues)\fC [inline]\fP, \fC [static]\fP"
- .PP
- \fBDb::customQuery\fP Can be used to send a complex query to the database\&.
- .PP
- \fBParameters\fP
- .RS 4
- \fIquery\fP - the full sql query statement
- .br
- \fIreturnValues\fP - the number of expected return values
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- QVector<QString> of results
- .RE
- .PP
- .SS "static QSqlDatabase Db::Database ()\fC [inline]\fP, \fC [static]\fP"
- .PP
- Can be used to access the database connection\&.
- .PP
- \fBReturns\fP
- .RS 4
- a pointer to the default database connection
- .RE
- .PP
- .SS "static bool Db::exists (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
- .PP
- \fBDb::exists\fP checks if a certain value exists in the database with a sqlite WHERE statement\&.
- .PP
- \fBParameters\fP
- .RS 4
- \fItable\fP - Name of the table
- .br
- \fIcolumn\fP - Name of the column
- .br
- \fIvalue\fP - The value to be checked
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- .RE
- .PP
- .SS "static QVector<QString> Db::multiSelect (QVector< QString > columns, QString table)\fC [inline]\fP, \fC [static]\fP"
- .PP
- \fBDb::multiSelect\fP Returns a complete column(s) for a given table\&.
- .PP
- \fBParameters\fP
- .RS 4
- \fIcolumn\fP - QVector<QString> Names of the columns to be queried
- .br
- \fItable\fP - QString Name of the table
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- .RE
- .PP
- .SS "static QVector<QString> Db::multiSelect (QVector< QString > columns, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
- .PP
- \fBDb::multiSelect\fP Returns multiple values from the database with a sqlite WHERE statement\&.
- .PP
- \fBParameters\fP
- .RS 4
- \fItable\fP - Name of the table
- .br
- \fIcolumns\fP - QVector<QString> Names of the columns to be queried
- .br
- \fIvalue\fP - Identifier for WHERE statement
- .br
- \fIcheckColumn\fP - column to match value to
- .br
- \fImatch\fP - enum Db::exactMatch or Db::partialMatch
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- QVector<QString>
- .RE
- .PP
- .SS "static QString Db::singleSelect (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
- .PP
- singleSelect Returns a single value from the database with a sqlite WHERE statement
- .PP
- \fBParameters\fP
- .RS 4
- \fItable\fP - Name of the table
- .br
- \fIcolumn\fP - Name of the column
- .br
- \fIvalue\fP - Identifier for WHERE statement
- .br
- \fImatch\fP - enum Db::exactMatch or Db::partialMatch
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- QString
- .RE
- .PP
- .SS "static bool Db::singleUpdate (QString table, QString column, QString value, QString checkColumn, QString checkvalue, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
- .PP
- \fBDb::singleUpdate\fP Updates a single value in the database\&. Query format: UPDATE table SET column = value WHERE checkcolumn =/LIKE checkvalue\&.
- .PP
- \fBParameters\fP
- .RS 4
- \fItable\fP Name of the table to be updated
- .br
- \fIcolumn\fP Name of the column to be updated
- .br
- \fIcheckColumn\fP Name of the column for WHERE statement
- .br
- \fIvalue\fP The value to be set
- .br
- \fIcheckvalue\fP The value for the WHERE statement
- .br
- \fImatch\fP enum Db::exactMatch or Db::partialMatch
- .RE
- .PP
- \fBReturns\fP
- .RS 4
- true on success, otherwise error messages in debug out
- .RE
- .PP
- .SH "Author"
- .PP
- Generated automatically by Doxygen for openPilotLog from the source code\&.
|