Db.3 7.3 KB

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