FMDatabase(FMDatabaseAdditions) Category Reference
| Declared in | FMDatabaseAdditions.h FMDatabaseAdditions.m |
Tasks
Return results of SQL to variable
-
– intForQuery:Return
intvalue for query -
– longForQuery:Return
longvalue for query -
– boolForQuery:Return
BOOLvalue for query -
– doubleForQuery:Return
doublevalue for query -
– stringForQuery:Return
NSStringvalue for query -
– dataForQuery:Return
NSDatavalue for query -
– dateForQuery:Return
NSDatevalue for query
Schema related operations
-
– tableExists:Does table exist in database?
-
– getSchemaThe schema of the database.
-
– getTableSchema:The schema of the database.
-
– columnExists:inTableWithName:Test to see if particular column exists for particular table in database
-
– columnExists:columnName:Test to see if particular column exists for particular table in database
-
– validateSQL:error:Validate SQL statement
Application identifier tasks
-
– applicationIDRetrieve application ID
-
– setApplicationID:Set the application ID
-
– applicationIDStringRetrieve application ID string
-
– setApplicationIDString:Set the application ID string
Instance Methods
applicationID
Retrieve application ID
- (uint32_t)applicationIDReturn Value
The uint32_t numeric value of the application ID.
See Also
Declared In
FMDatabaseAdditions.happlicationIDString
Retrieve application ID string
- (NSString *)applicationIDStringReturn Value
The NSString value of the application ID.
See Also
Declared In
FMDatabaseAdditions.hboolForQuery:
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
?placeholders in the SQL query.
Return Value
BOOL value.
Declared In
FMDatabaseAdditions.hcolumnExists: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
Warning: Deprecated - use columnExists:inTableWithName: instead.
See Also
Declared In
FMDatabaseAdditions.hcolumnExists: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.
Declared In
FMDatabaseAdditions.hdataForQuery:
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
?placeholders in the SQL query.
Return Value
NSData value.
Declared In
FMDatabaseAdditions.hdateForQuery:
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
?placeholders in the SQL query.
Return Value
NSDate value.
Declared In
FMDatabaseAdditions.hdoubleForQuery:
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
?placeholders in the SQL query.
Return Value
double value.
Declared In
FMDatabaseAdditions.hgetSchema
The schema of the database.
- (FMResultSet *)getSchemaReturn Value
FMResultSet of schema; nil on error.
Discussion
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.hgetTableSchema:
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
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.hintForQuery:
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
?placeholders in the SQL query.
Return Value
int value.
Declared In
FMDatabaseAdditions.hlongForQuery:
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
?placeholders in the SQL query.
Return Value
long value.
Declared In
FMDatabaseAdditions.hsetApplicationID:
Set the application ID
- (void)setApplicationID:(uint32_t)appIDParameters
- appID
The
uint32_tnumeric value of the application ID.
See Also
Declared In
FMDatabaseAdditions.hsetApplicationIDString:
Set the application ID string
- (void)setApplicationIDString:(NSString *)stringParameters
- string
The
NSStringvalue of the application ID.
See Also
Declared In
FMDatabaseAdditions.hstringForQuery:
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
?placeholders in the SQL query.
Return Value
NSString value.
Declared In
FMDatabaseAdditions.htableExists:
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.
Declared In
FMDatabaseAdditions.hvalidateSQL:error:
Validate SQL statement
- (BOOL)validateSQL:(NSString *)sql error:(NSError **)errorParameters
- sql
The SQL statement being validated.
- error
This is a pointer to a
NSErrorobject that will receive the autoreleasedNSErrorobject if there was any error. If this isnil, noNSErrorresult will be returned.
Return Value
YES if validation succeeded without incident; NO otherwise.
Discussion
This validates SQL statement by performing sqlite3_prepare_v2, but not returning the results, but instead immediately calling sqlite3_finalize.
Declared In
FMDatabaseAdditions.h