FMDatabase Class Reference
| Inherits from | NSObject |
| Declared in | FMDatabase.h FMDatabase.m |
Overview
A SQLite (http://sqlite.org/) Objective-C wrapper.
Usage
The three main classes in FMDB are:
FMDatabase- Represents a single SQLite database. Used for executing SQL statements.FMResultSet- Represents the results of executing a query on anFMDatabase.FMDatabaseQueue- If you want to perform queries and updates on multiple threads, you’ll want to use this class.
See also
FMDatabasePool- A pool ofFMDatabaseobjects.FMStatement- A wrapper forsqlite_stmt.
External links
- FMDB on GitHub including introductory documentation
- SQLite web site
- FMDB mailing list
- SQLite FAQ
Warning: Do not instantiate a single FMDatabase object and use it across multiple threads. Instead, use FMDatabaseQueue.
Tasks
Properties
-
traceExecutionWhether should trace execution
property -
checkedOutWhether checked out or not
property -
busyRetryTimeoutBusy retry timeout
property -
crashOnErrorsCrash on errors
property -
logsErrorsLogs errors
property -
cachedStatementsDictionary of cached statements
property
Initialization
-
+ databaseWithPath:Create a
FMDatabaseobject. -
– initWithPath:Initialize a
FMDatabaseobject.
Opening and closing database
-
– openOpening a new database connection
-
– openWithFlags:Opening a new database connection with flags
-
– closeClosing a database connection
-
– goodConnectionTest to see if we have a good connection to the database.
Perform updates
-
– update:withErrorAndBindings:Execute update statement
-
– executeUpdate:Execute update statement
-
– executeUpdateWithFormat:Execute update statement
-
– executeUpdate:withArgumentsInArray:Execute update statement
-
– executeUpdate:withParameterDictionary:Execute update statement
-
– lastInsertRowIdLast insert rowid
-
– changesThe number of rows changed by prior SQL statement.
Retrieving results
-
– executeQuery:Execute select statement
-
– executeQueryWithFormat:Execute select statement
-
– executeQuery:withArgumentsInArray:Execute select statement
-
– executeQuery:withParameterDictionary:Execute select statement
Transactions
-
– beginTransactionBegin a transaction
-
– beginDeferredTransactionBegin a deferred transaction
-
– commitCommit a transaction
-
– rollbackRollback a transaction
-
– inTransactionIdentify whether currently in a transaction or not
Cached statements and result sets
-
– clearCachedStatementsClear cached statements
-
– closeOpenResultSetsClose all open result sets
-
– hasOpenResultSetsWhether database has any open result sets
-
– shouldCacheStatementsReturn whether should cache statements or not
-
– setShouldCacheStatements:Set whether should cache statements or not
Encryption methods
-
– setKey:Set encryption key.
-
– rekey:Reset encryption key
-
– setKeyWithData:Set encryption key using
keyData. -
– rekeyWithData:Reset encryption key using
keyData.
General inquiry methods
-
– databasePathThe path of the database file
-
– sqliteHandleThe underlying SQLite handle
Retrieving error codes
-
– lastErrorMessageLast error message
-
– lastErrorCodeLast error code
-
– hadErrorHad error
-
– lastErrorLast error
Save points
-
– startSavePointWithName:error:Start save point
-
– releaseSavePointWithName:error:Release save point
-
– rollbackToSavePointWithName:error:Roll back to save point
-
– inSavePoint:Start save point
SQLite library status
-
+ isSQLiteThreadSafeTest to see if the library is threadsafe
-
+ sqliteLibVersionRun-time library version numbers
Make SQL function
-
– makeFunctionNamed:maximumArguments:withBlock:Adds SQL functions or aggregates or to redefine the behavior of existing SQL functions or aggregates.
Date formatter
-
+ storeableDateFormat:Generate an
NSDateFormatterthat won’t be broken by permutations of timezones or locales. -
– hasDateFormatterTest whether the database has a date formatter assigned.
-
– setDateFormat:Set to a date formatter to use string dates with sqlite instead of the default UNIX timestamps.
-
– dateFromString:Convert the supplied NSString to NSDate, using the current database formatter.
-
– stringFromDate:Convert the supplied NSDate to NSString, using the current database formatter.
Properties
busyRetryTimeout
Busy retry timeout
@property (atomic, assign) int busyRetryTimeoutDeclared In
FMDatabase.hcachedStatements
Dictionary of cached statements
@property (atomic, retain) NSMutableDictionary *cachedStatementsDeclared In
FMDatabase.hcheckedOut
Whether checked out or not
@property (atomic, assign) BOOL checkedOutDeclared In
FMDatabase.hClass Methods
databaseWithPath:
Create a FMDatabase object.
+ (instancetype)databaseWithPath:(NSString *)inPathParameters
- inPath
Path of database file
Return Value
FMDatabase object if successful; nil if failure.
Discussion
An FMDatabase is created with a path to a SQLite database file. This path can be one of these three:
- A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
- An empty string (
@""). An empty database is created at a temporary location. This database is deleted with theFMDatabaseconnection is closed. nil. An in-memory database is created. This database will be destroyed with theFMDatabaseconnection is closed.
For example, to create/open a database in your Mac OS X tmp folder:
FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
Or, in iOS, you might open a database in the app’s Documents directory:
NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
(For more information on temporary and in-memory databases, read the sqlite documentation on the subject: http://www.sqlite.org/inmemorydb.html)
Declared In
FMDatabase.hisSQLiteThreadSafe
Test to see if the library is threadsafe
+ (BOOL)isSQLiteThreadSafeReturn Value
Zero if and only if SQLite was compiled with mutexing code omitted due to the SQLITE_THREADSAFE compile-time option being set to 0.
See Also
Declared In
FMDatabase.hsqliteLibVersion
Run-time library version numbers
+ (NSString *)sqliteLibVersionSee Also
Declared In
FMDatabase.hstoreableDateFormat:
Generate an NSDateFormatter that won’t be broken by permutations of timezones or locales.
+ (NSDateFormatter *)storeableDateFormat:(NSString *)formatParameters
- format
A valid NSDateFormatter format string.
Return Value
A NSDateFormatter that can be used for converting dates to strings and vice versa.
Discussion
Use this method to generate values to set the dateFormat property.
Example:
myDB.dateFormat = [FMDatabase storeableDateFormat:@"yyyy-MM-dd HH:mm:ss"];
Warning: Note that NSDateFormatter is not thread-safe, so the formatter generated by this method should be assigned to only one FMDB instance and should not be used for other purposes.
See Also
Declared In
FMDatabase.hInstance Methods
beginDeferredTransaction
Begin a deferred transaction
- (BOOL)beginDeferredTransactionReturn Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hbeginTransaction
Begin a transaction
- (BOOL)beginTransactionReturn Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hchanges
The number of rows changed by prior SQL statement.
- (int)changesDiscussion
This function returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the database connection specified by the first parameter. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted.
See Also
Declared In
FMDatabase.hclearCachedStatements
Clear cached statements
- (void)clearCachedStatementsDeclared In
FMDatabase.hclose
Closing a database connection
- (BOOL)closeReturn Value
YES if success, NO on error.
See Also
Declared In
FMDatabase.hcommit
Commit a transaction
- (BOOL)commitReturn Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Commit a transaction that was initiated with either beginTransaction or with beginDeferredTransaction.
Declared In
FMDatabase.hdatabasePath
The path of the database file
- (NSString *)databasePathReturn Value
path of database.
Declared In
FMDatabase.hdateFromString:
Convert the supplied NSString to NSDate, using the current database formatter.
- (NSDate *)dateFromString:(NSString *)sParameters
- s
NSStringto convert toNSDate.
Return Value
nil if no formatter is set.
See Also
Declared In
FMDatabase.hexecuteQuery:
Execute select statement
- (FMResultSet *)executeQuery:(NSString *)sql, ...Parameters
- sql
The SELECT statement to be performed, with optional
?placeholders.
- ...
Optional parameters to bind to
?placeholders in the SQL statement.
Return Value
A FMResultSet for the result set upon success; nil upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Executing queries returns an FMResultSet object if successful, and nil upon failure. Like executing updates, there is a variant that accepts an NSError ** parameter. Otherwise you should use the lastErrorMessage and lastErrorMessage methods to determine why a query failed.
In order to iterate through the results of your query, you use a while() loop. You also need to “step” (via [FMResultSet next]) from one record to the other.
See Also
Declared In
FMDatabase.hexecuteQuery:withArgumentsInArray:
Execute select statement
- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)argumentsParameters
- sql
The SELECT statement to be performed, with optional
?placeholders.
- arguments
A
NSArrayof objects to be used when binding values to the?placeholders in the SQL statement.
Return Value
A FMResultSet for the result set upon success; nil upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Executing queries returns an FMResultSet object if successful, and nil upon failure. Like executing updates, there is a variant that accepts an NSError ** parameter. Otherwise you should use the lastErrorMessage and lastErrorMessage methods to determine why a query failed.
In order to iterate through the results of your query, you use a while() loop. You also need to “step” (via [FMResultSet next]) from one record to the other.
See Also
Declared In
FMDatabase.hexecuteQuery:withParameterDictionary:
Execute select statement
- (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)argumentsParameters
- sql
The SELECT statement to be performed, with optional
?placeholders.
- arguments
A
NSDictionaryof objects keyed by column names that will be used when binding values to the?placeholders in the SQL statement.
Return Value
A FMResultSet for the result set upon success; nil upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Executing queries returns an FMResultSet object if successful, and nil upon failure. Like executing updates, there is a variant that accepts an NSError ** parameter. Otherwise you should use the lastErrorMessage and lastErrorMessage methods to determine why a query failed.
In order to iterate through the results of your query, you use a while() loop. You also need to “step” (via [FMResultSet next]) from one record to the other.
See Also
Declared In
FMDatabase.hexecuteQueryWithFormat:
Execute select statement
- (FMResultSet *)executeQueryWithFormat:(NSString *)format, ...Parameters
- format
The SQL to be performed, with
printf-style escape sequences.
- ...
Optional parameters to bind to use in conjunction with the
printf-style escape sequences in the SQL statement.
Return Value
A FMResultSet for the result set upon success; nil upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Executing queries returns an FMResultSet object if successful, and nil upon failure. Like executing updates, there is a variant that accepts an NSError ** parameter. Otherwise you should use the lastErrorMessage and lastErrorMessage methods to determine why a query failed.
In order to iterate through the results of your query, you use a while() loop. You also need to “step” (via [FMResultSet next]) from one record to the other.
Warning: This should be used with great care. Generally, you should use executeQuery: (with ? placeholders) rather than this method.
See Also
Declared In
FMDatabase.hexecuteUpdate:
Execute update statement
- (BOOL)executeUpdate:(NSString *)sql, ...Parameters
- sql
The SQL to be performed, with optional
?placeholders.
- ...
Optional parameters to bind to
?placeholders in the SQL statement.
Return Value
YES upon success; NO upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hexecuteUpdate:withArgumentsInArray:
Execute update statement
- (BOOL)executeUpdate:(NSString *)sql withArgumentsInArray:(NSArray *)argumentsParameters
- sql
The SQL to be performed, with optional
?placeholders.
- arguments
A
NSArrayof objects to be used when binding values to the?placeholders in the SQL statement.
Return Value
YES upon success; NO upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Any sort of SQL statement which is not a SELECT statement qualifies as an update. This includes CREATE, UPDATE, INSERT, ALTER, COMMIT, BEGIN, DETACH, DELETE, DROP, END, EXPLAIN, VACUUM, and REPLACE statements (plus many more). Basically, if your SQL statement does not begin with SELECT, it is an update statement.
Declared In
FMDatabase.hexecuteUpdate:withParameterDictionary:
Execute update statement
- (BOOL)executeUpdate:(NSString *)sql withParameterDictionary:(NSDictionary *)argumentsParameters
- sql
The SQL to be performed, with optional
?placeholders.
- arguments
A
NSDictionaryof objects keyed by column names that will be used when binding values to the?placeholders in the SQL statement.
Return Value
YES upon success; NO upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Any sort of SQL statement which is not a SELECT statement qualifies as an update. This includes CREATE, UPDATE, INSERT, ALTER, COMMIT, BEGIN, DETACH, DELETE, DROP, END, EXPLAIN, VACUUM, and REPLACE statements (plus many more). Basically, if your SQL statement does not begin with SELECT, it is an update statement.
Declared In
FMDatabase.hexecuteUpdateWithFormat:
Execute update statement
- (BOOL)executeUpdateWithFormat:(NSString *)format, ...Parameters
- format
The SQL to be performed, with
printf-style escape sequences.
- ...
Optional parameters to bind to use in conjunction with the
printf-style escape sequences in the SQL statement.
Return Value
YES upon success; NO upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Any sort of SQL statement which is not a SELECT statement qualifies as an update. This includes CREATE, UPDATE, INSERT, ALTER, COMMIT, BEGIN, DETACH, DELETE, DROP, END, EXPLAIN, VACUUM, and REPLACE statements (plus many more). Basically, if your SQL statement does not begin with SELECT, it is an update statement.
Warning: This should be used with great care. Generally, you should use executeUpdate: (with ? placeholders) rather than this method.
Declared In
FMDatabase.hgoodConnection
Test to see if we have a good connection to the database.
- (BOOL)goodConnectionReturn Value
YES if everything succeeds, NO on failure.
Discussion
This will confirm whether:
- is database open
- if open, it will try a simple SELECT statement and confirm that it succeeds.
Declared In
FMDatabase.hhadError
Had error
- (BOOL)hadErrorReturn Value
YES if there was an error, NO if no error.
See Also
Declared In
FMDatabase.hhasDateFormatter
Test whether the database has a date formatter assigned.
- (BOOL)hasDateFormatterReturn Value
YES if there is a date formatter; NO if not.
See Also
Declared In
FMDatabase.hhasOpenResultSets
Whether database has any open result sets
- (BOOL)hasOpenResultSetsReturn Value
YES if there are open result sets; NO if not.
Declared In
FMDatabase.hinSavePoint:
Start save point
- (NSError *)inSavePoint:(void ( ^ ) ( BOOL *rollback ))blockParameters
- block
Block of code to perform from within save point.
Return Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
See Also
Declared In
FMDatabase.hinTransaction
Identify whether currently in a transaction or not
- (BOOL)inTransactionReturn Value
YES if currently within transaction; NO if not.
Declared In
FMDatabase.hinitWithPath:
Initialize a FMDatabase object.
- (instancetype)initWithPath:(NSString *)inPathParameters
- inPath
Path of database file
Return Value
FMDatabase object if successful; nil if failure.
Discussion
An FMDatabase is created with a path to a SQLite database file. This path can be one of these three:
- A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
- An empty string (
@""). An empty database is created at a temporary location. This database is deleted with theFMDatabaseconnection is closed. nil. An in-memory database is created. This database will be destroyed with theFMDatabaseconnection is closed.
For example, to create/open a database in your Mac OS X tmp folder:
FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
Or, in iOS, you might open a database in the app’s Documents directory:
NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
(For more information on temporary and in-memory databases, read the sqlite documentation on the subject: http://www.sqlite.org/inmemorydb.html)
Declared In
FMDatabase.hlastError
Last error
- (NSError *)lastErrorReturn Value
NSError representing the last error.
See Also
Declared In
FMDatabase.hlastErrorCode
Last error code
- (int)lastErrorCodeReturn Value
Integer value of the last error code.
Discussion
Returns the numeric result code or extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
Declared In
FMDatabase.hlastErrorMessage
Last error message
- (NSString *)lastErrorMessageReturn Value
NSString of the last error message.
Discussion
Returns the English-language text that describes the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
See Also
Declared In
FMDatabase.hlastInsertRowId
Last insert rowid
- (sqlite_int64)lastInsertRowIdDiscussion
Each entry in an SQLite table has a unique 64-bit signed integer key called the “rowid”. The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_ as long as those names are not also used by explicitly declared columns. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
This routine returns the rowid of the most recent successful INSERT into the database from the database connection in the first argument. As of SQLite version 3.7.7, this routines records the last insert rowid of both ordinary tables and virtual tables. If no successful INSERTs have ever occurred on that database connection, zero is returned.
See Also
Declared In
FMDatabase.hmakeFunctionNamed:maximumArguments:withBlock:
Adds SQL functions or aggregates or to redefine the behavior of existing SQL functions or aggregates.
- (void)makeFunctionNamed:(NSString *)name maximumArguments:(int)count withBlock:(void ( ^ ) ( sqlite3_context *context , int argc , sqlite3_value **argv ))blockParameters
- name
Name of function
- count
Maximum number of parameters
- block
The block of code for the function
Discussion
For example:
[queue inDatabase:^(FMDatabase *adb) {
[adb executeUpdate:@"create table ftest (foo text)"];
[adb executeUpdate:@"insert into ftest values ('hello')"];
[adb executeUpdate:@"insert into ftest values ('hi')"];
[adb executeUpdate:@"insert into ftest values ('not h!')"];
[adb executeUpdate:@"insert into ftest values ('definitely not h!')"];
[adb makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int aargc, sqlite3_value **aargv) {
if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) {
@autoreleasepool {
const char *c = (const char *)sqlite3_value_text(aargv[0]);
NSString *s = [NSString stringWithUTF8String:c];
sqlite3_result_int(context, [s hasPrefix:@"h"]);
}
}
else {
NSLog(@"Unknown formart for StringStartsWithH (%d) %s:%d", sqlite3_value_type(aargv[0]), __FUNCTION__, __LINE__);
sqlite3_result_null(context);
}
}];
int rowCount = 0;
FMResultSet *ars = [adb executeQuery:@"select * from ftest where StringStartsWithH(foo)"];
while ([ars next]) {
rowCount++;
NSLog(@"Does %@ start with 'h'?", [rs stringForColumnIndex:0]);
}
FMDBQuickCheck(rowCount == 2);
}];
See Also
Declared In
FMDatabase.hopen
Opening a new database connection
- (BOOL)openReturn Value
YES if successful, NO on error.
Discussion
The database is opened for reading and writing, and is created if it does not already exist.
See Also
Declared In
FMDatabase.hopenWithFlags:
Opening a new database connection with flags
- (BOOL)openWithFlags:(int)flagsParameters
- flags
one of the following three values, optionally combined with the
SQLITE_OPEN_NOMUTEX,SQLITE_OPEN_FULLMUTEX,SQLITE_OPEN_SHAREDCACHE,SQLITE_OPEN_PRIVATECACHE, and/orSQLITE_OPEN_URIflags:SQLITE_OPEN_READONLYThe database is opened in read-only mode. If the database does not already exist, an error is returned.
SQLITE_OPEN_READWRITEThe database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned.
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATEThe database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for
openmethod.
Return Value
YES if successful, NO on error.
See Also
Declared In
FMDatabase.hrekey:
Reset encryption key
- (BOOL)rekey:(NSString *)keyParameters
- key
The key to be used.
Return Value
YES if success, NO on error.
Discussion
Warning: You need to have purchased the sqlite encryption extensions for this method to work.
Declared In
FMDatabase.hrekeyWithData:
Reset encryption key using keyData.
- (BOOL)rekeyWithData:(NSData *)keyDataParameters
- keyData
The
NSDatato be used.
Return Value
YES if success, NO on error.
Discussion
Warning: You need to have purchased the sqlite encryption extensions for this method to work.
Declared In
FMDatabase.hreleaseSavePointWithName:error:
Release save point
- (BOOL)releaseSavePointWithName:(NSString *)name error:(NSError **)outErrParameters
- name
Name of save point.
- outErr
A
NSErrorobject to receive any error object (if any).
Return Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hrollback
Rollback a transaction
- (BOOL)rollbackReturn Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Discussion
Rollback a transaction that was initiated with either beginTransaction or with beginDeferredTransaction.
Declared In
FMDatabase.hrollbackToSavePointWithName:error:
Roll back to save point
- (BOOL)rollbackToSavePointWithName:(NSString *)name error:(NSError **)outErrParameters
- name
Name of save point.
- outErr
A
NSErrorobject to receive any error object (if any).
Return Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hsetDateFormat:
Set to a date formatter to use string dates with sqlite instead of the default UNIX timestamps.
- (void)setDateFormat:(NSDateFormatter *)formatParameters
- format
Set to nil to use UNIX timestamps. Defaults to nil. Should be set using a formatter generated using FMDatabase::storeableDateFormat.
Discussion
Warning: Note there is no direct getter for the NSDateFormatter, and you should not use the formatter you pass to FMDB for other purposes, as NSDateFormatter is not thread-safe.
See Also
Declared In
FMDatabase.hsetKey:
Set encryption key.
- (BOOL)setKey:(NSString *)keyParameters
- key
The key to be used.
Return Value
YES if success, NO on error.
Discussion
Warning: You need to have purchased the sqlite encryption extensions for this method to work.
Declared In
FMDatabase.hsetKeyWithData:
Set encryption key using keyData.
- (BOOL)setKeyWithData:(NSData *)keyDataParameters
- keyData
The
NSDatato be used.
Return Value
YES if success, NO on error.
Discussion
Warning: You need to have purchased the sqlite encryption extensions for this method to work.
Declared In
FMDatabase.hsetShouldCacheStatements:
Set whether should cache statements or not
- (void)setShouldCacheStatements:(BOOL)valueParameters
- value
YESif should cache statements;NOif not.
Declared In
FMDatabase.hshouldCacheStatements
Return whether should cache statements or not
- (BOOL)shouldCacheStatementsReturn Value
YES if should cache statements; NO if not.
Declared In
FMDatabase.hsqliteHandle
The underlying SQLite handle
- (sqlite3 *)sqliteHandleReturn Value
The sqlite3 pointer.
Declared In
FMDatabase.hstartSavePointWithName:error:
Start save point
- (BOOL)startSavePointWithName:(NSString *)name error:(NSError **)outErrParameters
- name
Name of save point.
- outErr
A
NSErrorobject to receive any error object (if any).
Return Value
YES on success; NO on failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.hstringFromDate:
Convert the supplied NSDate to NSString, using the current database formatter.
- (NSString *)stringFromDate:(NSDate *)dateParameters
- date
NSDateof date to convert toNSString.
Return Value
nil if no formatter is set.
See Also
Declared In
FMDatabase.hupdate:withErrorAndBindings:
Execute update statement
- (BOOL)update:(NSString *)sql withErrorAndBindings:(NSError **)outErr, ...Parameters
- sql
The SQL to be performed, with optional
?placeholders.
- outErr
A reference to the
NSErrorpointer to be updated with an auto releasedNSErrorobject if an error if an error occurs. Ifnil, noNSErrorobject will be returned.
- ...
Optional parameters to bind to
?placeholders in the SQL statement.
Return Value
YES upon success; NO upon failure. If failed, you can call lastError, lastErrorCode, or lastErrorMessage for diagnostic information regarding the failure.
Declared In
FMDatabase.h