FMDatabase.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #import <Foundation/Foundation.h>
  2. #import "sqlite3.h"
  3. #import "FMResultSet.h"
  4. @interface FMDatabase : NSObject
  5. {
  6. sqlite3* db;
  7. NSString* databasePath;
  8. BOOL logsErrors;
  9. BOOL crashOnErrors;
  10. BOOL inUse;
  11. BOOL inTransaction;
  12. BOOL traceExecution;
  13. BOOL checkedOut;
  14. int busyRetryTimeout;
  15. BOOL shouldCacheStatements;
  16. NSMutableDictionary *cachedStatements;
  17. NSMutableSet *openResultSets;
  18. }
  19. + (id)databaseWithPath:(NSString*)inPath;
  20. - (id)initWithPath:(NSString*)inPath;
  21. - (BOOL)open;
  22. #if SQLITE_VERSION_NUMBER >= 3005000
  23. - (BOOL)openWithFlags:(int)flags;
  24. #endif
  25. - (BOOL)close;
  26. - (BOOL)goodConnection;
  27. - (void)clearCachedStatements;
  28. - (void)closeOpenResultSets;
  29. // encryption methods. You need to have purchased the sqlite encryption extensions for these to work.
  30. - (BOOL)setKey:(NSString*)key;
  31. - (BOOL)rekey:(NSString*)key;
  32. - (NSString *)databasePath;
  33. - (NSString*)lastErrorMessage;
  34. - (int)lastErrorCode;
  35. - (BOOL)hadError;
  36. - (sqlite_int64)lastInsertRowId;
  37. - (sqlite3*)sqliteHandle;
  38. - (BOOL)update:(NSString*)sql error:(NSError**)outErr bind:(id)bindArgs, ...;
  39. - (BOOL)executeUpdate:(NSString*)sql, ...;
  40. - (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
  41. - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArray:(NSArray*)arrayArgs orVAList:(va_list)args; // you shouldn't ever need to call this. use the previous two instead.
  42. - (FMResultSet *)executeQuery:(NSString*)sql, ...;
  43. - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments;
  44. - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orVAList:(va_list)args; // you shouldn't ever need to call this. use the previous two instead.
  45. - (BOOL)rollback;
  46. - (BOOL)commit;
  47. - (BOOL)beginTransaction;
  48. - (BOOL)beginDeferredTransaction;
  49. - (BOOL)logsErrors;
  50. - (void)setLogsErrors:(BOOL)flag;
  51. - (BOOL)crashOnErrors;
  52. - (void)setCrashOnErrors:(BOOL)flag;
  53. - (BOOL)inUse;
  54. - (void)setInUse:(BOOL)value;
  55. - (BOOL)inTransaction;
  56. - (void)setInTransaction:(BOOL)flag;
  57. - (BOOL)traceExecution;
  58. - (void)setTraceExecution:(BOOL)flag;
  59. - (BOOL)checkedOut;
  60. - (void)setCheckedOut:(BOOL)flag;
  61. - (int)busyRetryTimeout;
  62. - (void)setBusyRetryTimeout:(int)newBusyRetryTimeout;
  63. - (BOOL)shouldCacheStatements;
  64. - (void)setShouldCacheStatements:(BOOL)value;
  65. - (NSMutableDictionary *)cachedStatements;
  66. - (void)setCachedStatements:(NSMutableDictionary *)value;
  67. + (NSString*)sqliteLibVersion;
  68. - (int)changes;
  69. @end
  70. @interface FMStatement : NSObject {
  71. sqlite3_stmt *statement;
  72. NSString *query;
  73. long useCount;
  74. }
  75. - (void)close;
  76. - (void)reset;
  77. - (sqlite3_stmt *)statement;
  78. - (void)setStatement:(sqlite3_stmt *)value;
  79. - (NSString *)query;
  80. - (void)setQuery:(NSString *)value;
  81. - (long)useCount;
  82. - (void)setUseCount:(long)value;
  83. @end