No Description

AWSFMDatabaseAdditions.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //
  2. // FMDatabaseAdditions.h
  3. // fmdb
  4. //
  5. // Created by August Mueller on 10/30/05.
  6. // Copyright 2005 Flying Meat Inc.. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "AWSFMDatabase.h"
  10. /** Category of additions for `<FMDatabase>` class.
  11. ### See also
  12. - `<FMDatabase>`
  13. */
  14. @interface AWSFMDatabase (AWSFMDatabaseAdditions)
  15. ///----------------------------------------
  16. /// @name Return results of SQL to variable
  17. ///----------------------------------------
  18. /** Return `int` value for query
  19. @param query The SQL query to be performed.
  20. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  21. @return `int` value.
  22. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  23. */
  24. - (int)intForQuery:(NSString*)query, ...;
  25. /** Return `long` value for query
  26. @param query The SQL query to be performed.
  27. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  28. @return `long` value.
  29. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  30. */
  31. - (long)longForQuery:(NSString*)query, ...;
  32. /** Return `BOOL` value for query
  33. @param query The SQL query to be performed.
  34. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  35. @return `BOOL` value.
  36. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  37. */
  38. - (BOOL)boolForQuery:(NSString*)query, ...;
  39. /** Return `double` value for query
  40. @param query The SQL query to be performed.
  41. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  42. @return `double` value.
  43. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  44. */
  45. - (double)doubleForQuery:(NSString*)query, ...;
  46. /** Return `NSString` value for query
  47. @param query The SQL query to be performed.
  48. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  49. @return `NSString` value.
  50. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  51. */
  52. - (NSString*)stringForQuery:(NSString*)query, ...;
  53. /** Return `NSData` value for query
  54. @param query The SQL query to be performed.
  55. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  56. @return `NSData` value.
  57. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  58. */
  59. - (NSData*)dataForQuery:(NSString*)query, ...;
  60. /** Return `NSDate` value for query
  61. @param query The SQL query to be performed.
  62. @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
  63. @return `NSDate` value.
  64. @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
  65. */
  66. - (NSDate*)dateForQuery:(NSString*)query, ...;
  67. // Notice that there's no dataNoCopyForQuery:.
  68. // That would be a bad idea, because we close out the result set, and then what
  69. // happens to the data that we just didn't copy? Who knows, not I.
  70. ///--------------------------------
  71. /// @name Schema related operations
  72. ///--------------------------------
  73. /** Does table exist in database?
  74. @param tableName The name of the table being looked for.
  75. @return `YES` if table found; `NO` if not found.
  76. */
  77. - (BOOL)tableExists:(NSString*)tableName;
  78. /** The schema of the database.
  79. This will be the schema for the entire database. For each entity, each row of the result set will include the following fields:
  80. - `type` - The type of entity (e.g. table, index, view, or trigger)
  81. - `name` - The name of the object
  82. - `tbl_name` - The name of the table to which the object references
  83. - `rootpage` - The page number of the root b-tree page for tables and indices
  84. - `sql` - The SQL that created the entity
  85. @return `FMResultSet` of schema; `nil` on error.
  86. @see [SQLite File Format](http://www.sqlite.org/fileformat.html)
  87. */
  88. - (AWSFMResultSet*)getSchema;
  89. /** The schema of the database.
  90. This will be the schema for a particular table as report by SQLite `PRAGMA`, for example:
  91. PRAGMA table_info('employees')
  92. This will report:
  93. - `cid` - The column ID number
  94. - `name` - The name of the column
  95. - `type` - The data type specified for the column
  96. - `notnull` - whether the field is defined as NOT NULL (i.e. values required)
  97. - `dflt_value` - The default value for the column
  98. - `pk` - Whether the field is part of the primary key of the table
  99. @param tableName The name of the table for whom the schema will be returned.
  100. @return `FMResultSet` of schema; `nil` on error.
  101. @see [table_info](http://www.sqlite.org/pragma.html#pragma_table_info)
  102. */
  103. - (AWSFMResultSet*)getTableSchema:(NSString*)tableName;
  104. /** Test to see if particular column exists for particular table in database
  105. @param columnName The name of the column.
  106. @param tableName The name of the table.
  107. @return `YES` if column exists in table in question; `NO` otherwise.
  108. */
  109. - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
  110. /** Test to see if particular column exists for particular table in database
  111. @param columnName The name of the column.
  112. @param tableName The name of the table.
  113. @return `YES` if column exists in table in question; `NO` otherwise.
  114. @see columnExists:inTableWithName:
  115. @warning Deprecated - use `<columnExists:inTableWithName:>` instead.
  116. */
  117. - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated));
  118. /** Validate SQL statement
  119. This validates SQL statement by performing `sqlite3_prepare_v2`, but not returning the results, but instead immediately calling `sqlite3_finalize`.
  120. @param sql The SQL statement being validated.
  121. @param error This is a pointer to a `NSError` object that will receive the autoreleased `NSError` object if there was any error. If this is `nil`, no `NSError` result will be returned.
  122. @return `YES` if validation succeeded without incident; `NO` otherwise.
  123. */
  124. - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
  125. ///-----------------------------------
  126. /// @name Application identifier tasks
  127. ///-----------------------------------
  128. /** Retrieve application ID
  129. @return The `uint32_t` numeric value of the application ID.
  130. @see setApplicationID:
  131. */
  132. - (uint32_t)applicationID;
  133. /** Set the application ID
  134. @param appID The `uint32_t` numeric value of the application ID.
  135. @see applicationID
  136. */
  137. - (void)setApplicationID:(uint32_t)appID;
  138. #if TARGET_OS_MAC && !TARGET_OS_IPHONE
  139. /** Retrieve application ID string
  140. @return The `NSString` value of the application ID.
  141. @see setApplicationIDString:
  142. */
  143. - (NSString*)applicationIDString;
  144. /** Set the application ID string
  145. @param string The `NSString` value of the application ID.
  146. @see applicationIDString
  147. */
  148. - (void)setApplicationIDString:(NSString*)string;
  149. #endif
  150. ///-----------------------------------
  151. /// @name user version identifier tasks
  152. ///-----------------------------------
  153. /** Retrieve user version
  154. @return The `uint32_t` numeric value of the user version.
  155. @see setUserVersion:
  156. */
  157. - (uint32_t)userVersion;
  158. /** Set the user-version
  159. @param version The `uint32_t` numeric value of the user version.
  160. @see userVersion
  161. */
  162. - (void)setUserVersion:(uint32_t)version;
  163. @end