FMDatabase(FMDatabaseAdditions) Category Reference
| Declared in | FMDatabaseAdditions.h |
|---|
Return results of SQL to variable
– intForQuery:
Return int value for query
- (int)intForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
int value.
Discussion
Return int value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– longForQuery:
Return long value for query
- (long)longForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
long value.
Discussion
Return long value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– boolForQuery:
Return BOOL value for query
- (BOOL)boolForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
BOOL value.
Discussion
Return BOOL value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– doubleForQuery:
Return double value for query
- (double)doubleForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
double value.
Discussion
Return double value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– stringForQuery:
Return NSString value for query
- (NSString *)stringForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
NSString value.
Discussion
Return NSString value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– dataForQuery:
Return NSData value for query
- (NSData *)dataForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
NSData value.
Discussion
Return NSData value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
– dateForQuery:
Return NSDate value for query
- (NSDate *)dateForQuery:(NSString *)query, ...Parameters
query |
The SQL query to be performed. |
|---|---|
... |
A list of parameters that will be bound to the |
Return Value
NSDate value.
Discussion
Return NSDate value for query
Note: To use this method from Swift, you must include FMDatabaseAdditionsVariadic.swift in your project.
Declared In
FMDatabaseAdditions.h
Schema related operations
– tableExists:
Does table exist in database?
- (BOOL)tableExists:(NSString *)tableNameParameters
tableName |
The name of the table being looked for. |
|---|
Return Value
YES if table found; NO if not found.
Discussion
Does table exist in database?
Declared In
FMDatabaseAdditions.h
– getSchema
The schema of the database.
- (FMResultSet *)getSchemaReturn Value
FMResultSet of schema; nil on error.
Discussion
The schema of the database.
This will be the schema for the entire database. For each entity, each row of the result set will include the following fields:
type- The type of entity (e.g. table, index, view, or trigger)name- The name of the objecttbl_name- The name of the table to which the object referencesrootpage- The page number of the root b-tree page for tables and indicessql- The SQL that created the entity
See Also
Declared In
FMDatabaseAdditions.h
– getTableSchema:
The schema of the database.
- (FMResultSet *)getTableSchema:(NSString *)tableNameParameters
tableName |
The name of the table for whom the schema will be returned. |
|---|
Return Value
FMResultSet of schema; nil on error.
Discussion
The schema of the database.
This will be the schema for a particular table as report by SQLite PRAGMA, for example:
PRAGMA table_info('employees')
This will report:
cid- The column ID numbername- The name of the columntype- The data type specified for the columnnotnull- whether the field is defined as NOT NULL (i.e. values required)dflt_value- The default value for the columnpk- Whether the field is part of the primary key of the table
See Also
Declared In
FMDatabaseAdditions.h
– columnExists:inTableWithName:
Test to see if particular column exists for particular table in database
- (BOOL)columnExists:(NSString *)columnName inTableWithName:(NSString *)tableNameParameters
columnName |
The name of the column. |
|---|---|
tableName |
The name of the table. |
Return Value
YES if column exists in table in question; NO otherwise.
Discussion
Test to see if particular column exists for particular table in database
Declared In
FMDatabaseAdditions.h
– columnExists:columnName:
Test to see if particular column exists for particular table in database
- (BOOL)columnExists:(NSString *)tableName columnName:(NSString *)columnNameParameters
tableName |
The name of the table. |
|---|---|
columnName |
The name of the column. |
Return Value
YES if column exists in table in question; NO otherwise.
Discussion
Test to see if particular column exists for particular table in database
Warning: Deprecated - use columnExists:inTableWithName: instead.
See Also
Declared In
FMDatabaseAdditions.h
– validateSQL:error:
Validate SQL statement
- (BOOL)validateSQL:(NSString *)sql error:(NSError **)errorParameters
sql |
The SQL statement being validated. |
|---|---|
error |
This is a pointer to a |
Return Value
YES if validation succeeded without incident; NO otherwise.
Discussion
Validate SQL statement
This validates SQL statement by performing sqlite3_prepare_v2, but not returning the results, but instead immediately calling sqlite3_finalize.
Declared In
FMDatabaseAdditions.h
Application identifier tasks
– applicationID
Retrieve application ID
- (uint32_t)applicationIDReturn Value
The uint32_t numeric value of the application ID.
Discussion
Retrieve application ID
See Also
Declared In
FMDatabaseAdditions.h
– setApplicationID:
Set the application ID
- (void)setApplicationID:(uint32_t)appIDParameters
appID |
The |
|---|
Discussion
Set the application ID
See Also
Declared In
FMDatabaseAdditions.h
– applicationIDString
Retrieve application ID string
- (NSString *)applicationIDStringReturn Value
The NSString value of the application ID.
Discussion
Retrieve application ID string
See Also
Declared In
FMDatabaseAdditions.h
– setApplicationIDString:
Set the application ID string
- (void)setApplicationIDString:(NSString *)stringParameters
string |
The |
|---|
Discussion
Set the application ID string
See Also
Declared In
FMDatabaseAdditions.h
user version identifier tasks
– userVersion
Retrieve user version
- (uint32_t)userVersionReturn Value
The uint32_t numeric value of the user version.
Discussion
Retrieve user version
See Also
Declared In
FMDatabaseAdditions.h
– setUserVersion:
Set the user-version
- (void)setUserVersion:(uint32_t)versionParameters
version |
The |
|---|
Discussion
Set the user-version
See Also
Declared In
FMDatabaseAdditions.h