|
|
@@ -336,23 +336,52 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary
|
|
|
- (BOOL)executeUpdateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
|
|
|
|
|
|
/** Execute single update statement
|
|
|
-
|
|
|
+
|
|
|
This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) binding any `?` placeholders in the SQL with the optional list of parameters.
|
|
|
+
|
|
|
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
|
|
|
+
|
|
|
+ @param sql The SQL to be performed, with optional `?` placeholders.
|
|
|
+
|
|
|
+ @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
|
|
|
+
|
|
|
+ @return `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`, `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
|
|
|
+
|
|
|
+ @see executeUpdate:values:error:
|
|
|
+ @see lastError
|
|
|
+ @see lastErrorCode
|
|
|
+ @see lastErrorMessage
|
|
|
+ */
|
|
|
+
|
|
|
+- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
|
|
|
|
|
|
+/** Execute single update statement
|
|
|
+
|
|
|
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) binding any `?` placeholders in the SQL with the optional list of parameters.
|
|
|
+
|
|
|
The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
|
|
|
+
|
|
|
+ This is similar to `<executeUpdate:withArgumentsInArray:>`, except that this also accepts a pointer to a `NSError` pointer, so that errors can be returned.
|
|
|
|
|
|
+ In Swift 2, this throws errors, as if it were defined as follows:
|
|
|
+
|
|
|
+ `func executeUpdate(sql: String!, values: [AnyObject]!) throws -> Bool`
|
|
|
+
|
|
|
@param sql The SQL to be performed, with optional `?` placeholders.
|
|
|
+
|
|
|
+ @param values A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
|
|
|
|
|
|
- @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
|
|
|
+ @param error A `NSError` object to receive any error object (if any).
|
|
|
|
|
|
@return `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`, `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
|
|
|
-
|
|
|
+
|
|
|
@see lastError
|
|
|
@see lastErrorCode
|
|
|
@see lastErrorMessage
|
|
|
+
|
|
|
*/
|
|
|
|
|
|
-- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
|
|
|
+- (BOOL)executeUpdate:(NSString*)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error;
|
|
|
|
|
|
/** Execute single update statement
|
|
|
|
|
|
@@ -524,12 +553,42 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary
|
|
|
|
|
|
@return 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.
|
|
|
|
|
|
+ @see -executeQuery:values:error:
|
|
|
@see FMResultSet
|
|
|
@see [`FMResultSet next`](<[FMResultSet next]>)
|
|
|
*/
|
|
|
|
|
|
- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments;
|
|
|
|
|
|
+/** Execute select statement
|
|
|
+
|
|
|
+ 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.
|
|
|
+
|
|
|
+ This is similar to `<executeQuery:withArgumentsInArray:>`, except that this also accepts a pointer to a `NSError` pointer, so that errors can be returned.
|
|
|
+
|
|
|
+ In Swift 2, this throws errors, as if it were defined as follows:
|
|
|
+
|
|
|
+ `func executeQuery(sql: String!, values: [AnyObject]!) throws -> FMResultSet!`
|
|
|
+
|
|
|
+ @param sql The SELECT statement to be performed, with optional `?` placeholders.
|
|
|
+
|
|
|
+ @param values A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
|
|
|
+
|
|
|
+ @param error A `NSError` object to receive any error object (if any).
|
|
|
+
|
|
|
+ @return 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.
|
|
|
+
|
|
|
+ @see FMResultSet
|
|
|
+ @see [`FMResultSet next`](<[FMResultSet next]>)
|
|
|
+
|
|
|
+ @note When called from Swift, only use the first two parameters, `sql` and `values`. This but throws the error.
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+- (FMResultSet *)executeQuery:(NSString *)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error;
|
|
|
+
|
|
|
/** Execute select statement
|
|
|
|
|
|
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.
|