Db.3 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. .TH "Db" 3 "Sun Dec 27 2020" "openPilotLog" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. 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');\&.
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .PP
  10. \fC#include <db\&.h>\fP
  11. .SS "Public Types"
  12. .in +1c
  13. .ti -1c
  14. .RI "enum \fBeditRole\fP { \fBcreateNew\fP, \fBeditExisting\fP }"
  15. .br
  16. .RI "The editRole enum {createNew, editExisting} is used to differentiate between creating a new entry in the database vs editing an existing one\&. "
  17. .ti -1c
  18. .RI "enum \fBmatchType\fP { \fBexactMatch\fP, \fBpartialMatch\fP }"
  19. .br
  20. .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\&. "
  21. .in -1c
  22. .SS "Public Member Functions"
  23. .in +1c
  24. .ti -1c
  25. .RI "\fBDb\fP (\fBDb\fP const &)=delete"
  26. .br
  27. .ti -1c
  28. .RI "void \fBoperator=\fP (\fBDb\fP const &)=delete"
  29. .br
  30. .in -1c
  31. .SS "Static Public Member Functions"
  32. .in +1c
  33. .ti -1c
  34. .RI "static \fBDb\fP & \fBget\fP ()"
  35. .br
  36. .ti -1c
  37. .RI "static void \fBconnect\fP ()"
  38. .br
  39. .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\&. "
  40. .ti -1c
  41. .RI "static void \fBdisconnect\fP ()"
  42. .br
  43. .RI "disconnect Closes and removes the default database connection\&. "
  44. .ti -1c
  45. .RI "static QSqlDatabase \fBDatabase\fP ()"
  46. .br
  47. .RI "Can be used to access the database connection\&. "
  48. .ti -1c
  49. .RI "static bool \fBexists\fP (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
  50. .br
  51. .RI "\fBDb::exists\fP checks if a certain value exists in the database with a sqlite WHERE statement\&. "
  52. .ti -1c
  53. .RI "static bool \fBsingleUpdate\fP (QString table, QString column, QString value, QString checkColumn, QString checkvalue, \fBDb::matchType\fP match)"
  54. .br
  55. .RI "\fBDb::singleUpdate\fP Updates a single value in the database\&. Query format: UPDATE table SET column = value WHERE checkcolumn =/LIKE checkvalue\&. "
  56. .ti -1c
  57. .RI "static QString \fBsingleSelect\fP (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
  58. .br
  59. .RI "singleSelect Returns a single value from the database with a sqlite WHERE statement "
  60. .ti -1c
  61. .RI "static QVector< QString > \fBmultiSelect\fP (QVector< QString > columns, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)"
  62. .br
  63. .RI "\fBDb::multiSelect\fP Returns multiple values from the database with a sqlite WHERE statement\&. "
  64. .ti -1c
  65. .RI "static QVector< QString > \fBmultiSelect\fP (QVector< QString > columns, QString table)"
  66. .br
  67. .RI "\fBDb::multiSelect\fP Returns a complete column(s) for a given table\&. "
  68. .ti -1c
  69. .RI "static QVector< QString > \fBcustomQuery\fP (QString query, int returnValues)"
  70. .br
  71. .RI "\fBDb::customQuery\fP Can be used to send a complex query to the database\&. "
  72. .in -1c
  73. .SH "Detailed Description"
  74. .PP
  75. 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');\&.
  76. .SH "Member Function Documentation"
  77. .PP
  78. .SS "static QVector<QString> Db::customQuery (QString query, int returnValues)\fC [inline]\fP, \fC [static]\fP"
  79. .PP
  80. \fBDb::customQuery\fP Can be used to send a complex query to the database\&.
  81. .PP
  82. \fBParameters\fP
  83. .RS 4
  84. \fIquery\fP - the full sql query statement
  85. .br
  86. \fIreturnValues\fP - the number of expected return values
  87. .RE
  88. .PP
  89. \fBReturns\fP
  90. .RS 4
  91. QVector<QString> of results
  92. .RE
  93. .PP
  94. .SS "static QSqlDatabase Db::Database ()\fC [inline]\fP, \fC [static]\fP"
  95. .PP
  96. Can be used to access the database connection\&.
  97. .PP
  98. \fBReturns\fP
  99. .RS 4
  100. a pointer to the default database connection
  101. .RE
  102. .PP
  103. .SS "static bool Db::exists (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
  104. .PP
  105. \fBDb::exists\fP checks if a certain value exists in the database with a sqlite WHERE statement\&.
  106. .PP
  107. \fBParameters\fP
  108. .RS 4
  109. \fItable\fP - Name of the table
  110. .br
  111. \fIcolumn\fP - Name of the column
  112. .br
  113. \fIvalue\fP - The value to be checked
  114. .RE
  115. .PP
  116. \fBReturns\fP
  117. .RS 4
  118. .RE
  119. .PP
  120. .SS "static QVector<QString> Db::multiSelect (QVector< QString > columns, QString table)\fC [inline]\fP, \fC [static]\fP"
  121. .PP
  122. \fBDb::multiSelect\fP Returns a complete column(s) for a given table\&.
  123. .PP
  124. \fBParameters\fP
  125. .RS 4
  126. \fIcolumn\fP - QVector<QString> Names of the columns to be queried
  127. .br
  128. \fItable\fP - QString Name of the table
  129. .RE
  130. .PP
  131. \fBReturns\fP
  132. .RS 4
  133. .RE
  134. .PP
  135. .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"
  136. .PP
  137. \fBDb::multiSelect\fP Returns multiple values from the database with a sqlite WHERE statement\&.
  138. .PP
  139. \fBParameters\fP
  140. .RS 4
  141. \fItable\fP - Name of the table
  142. .br
  143. \fIcolumns\fP - QVector<QString> Names of the columns to be queried
  144. .br
  145. \fIvalue\fP - Identifier for WHERE statement
  146. .br
  147. \fIcheckColumn\fP - column to match value to
  148. .br
  149. \fImatch\fP - enum Db::exactMatch or Db::partialMatch
  150. .RE
  151. .PP
  152. \fBReturns\fP
  153. .RS 4
  154. QVector<QString>
  155. .RE
  156. .PP
  157. .SS "static QString Db::singleSelect (QString column, QString table, QString checkColumn, QString value, \fBDb::matchType\fP match)\fC [inline]\fP, \fC [static]\fP"
  158. .PP
  159. singleSelect Returns a single value from the database with a sqlite WHERE statement
  160. .PP
  161. \fBParameters\fP
  162. .RS 4
  163. \fItable\fP - Name of the table
  164. .br
  165. \fIcolumn\fP - Name of the column
  166. .br
  167. \fIvalue\fP - Identifier for WHERE statement
  168. .br
  169. \fImatch\fP - enum Db::exactMatch or Db::partialMatch
  170. .RE
  171. .PP
  172. \fBReturns\fP
  173. .RS 4
  174. QString
  175. .RE
  176. .PP
  177. .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"
  178. .PP
  179. \fBDb::singleUpdate\fP Updates a single value in the database\&. Query format: UPDATE table SET column = value WHERE checkcolumn =/LIKE checkvalue\&.
  180. .PP
  181. \fBParameters\fP
  182. .RS 4
  183. \fItable\fP Name of the table to be updated
  184. .br
  185. \fIcolumn\fP Name of the column to be updated
  186. .br
  187. \fIcheckColumn\fP Name of the column for WHERE statement
  188. .br
  189. \fIvalue\fP The value to be set
  190. .br
  191. \fIcheckvalue\fP The value for the WHERE statement
  192. .br
  193. \fImatch\fP enum Db::exactMatch or Db::partialMatch
  194. .RE
  195. .PP
  196. \fBReturns\fP
  197. .RS 4
  198. true on success, otherwise error messages in debug out
  199. .RE
  200. .PP
  201. .SH "Author"
  202. .PP
  203. Generated automatically by Doxygen for openPilotLog from the source code\&.