|
|
@@ -38,6 +38,10 @@
|
|
|
#define instancetype id
|
|
|
#endif
|
|
|
|
|
|
+
|
|
|
+typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
+
|
|
|
+
|
|
|
/** A SQLite ([http://sqlite.org/](http://sqlite.org/)) Objective-C wrapper.
|
|
|
|
|
|
### Usage
|
|
|
@@ -261,9 +265,11 @@
|
|
|
|
|
|
- (BOOL)update:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ...;
|
|
|
|
|
|
-/** Execute update statement
|
|
|
+/** Execute single update statement
|
|
|
|
|
|
- This method employs [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) for any optional value parameters. This properly escapes any characters that need escape sequences (e.g. quotation marks), which eliminates simple SQL errors as well as protects against SQL injection attacks. This method natively handles `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects. All other object types will be interpreted as text values using the object's `description` method.
|
|
|
+ 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), [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) to bind values to `?` placeholders in the SQL with the optional list of parameters, and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update.
|
|
|
+
|
|
|
+ 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.
|
|
|
|
|
|
@@ -338,6 +344,41 @@
|
|
|
// Documentation forthcoming.
|
|
|
- (BOOL)executeUpdate:(NSString*)sql withVAList: (va_list)args;
|
|
|
|
|
|
+/** Execute multiple SQL statements
|
|
|
+
|
|
|
+ This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
|
|
|
+
|
|
|
+ @param sql The SQL to be performed
|
|
|
+
|
|
|
+ @return `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`, `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
|
|
|
+
|
|
|
+ @see executeBulkSQL:userInfo:block:
|
|
|
+ @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+- (BOOL)executeBulkSQL:(NSString *)sql;
|
|
|
+
|
|
|
+/** Execute multiple SQL statements with callback handler
|
|
|
+
|
|
|
+ This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
|
|
|
+
|
|
|
+ @param sql The SQL to be performed.
|
|
|
+ @param block A block that will be called for any result sets returned by any SQL statements.
|
|
|
+ Note, if you supply this block, it must return integer value, zero upon success,
|
|
|
+ non-zero value upon failure (which will stop the bulk execution of the SQL. This block
|
|
|
+ takes two parameters, the `void *userInfo` and a `NSDictionary *resultsDictionary`.
|
|
|
+ This may be `nil`.
|
|
|
+
|
|
|
+ @return `YES` upon success; `NO` upon failure. If failed, you can call `<lastError>`,
|
|
|
+ `<lastErrorCode>`, or `<lastErrorMessage>` for diagnostic information regarding the failure.
|
|
|
+
|
|
|
+ @see executeBulkSQL:
|
|
|
+ @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+- (BOOL)executeBulkSQL:(NSString *)sql block:(ExecuteBulkSQLCallbackBlock)block;
|
|
|
|
|
|
/** Last insert rowid
|
|
|
|
|
|
@@ -449,8 +490,6 @@
|
|
|
// Documentation forthcoming.
|
|
|
- (FMResultSet *)executeQuery:(NSString*)sql withVAList: (va_list)args;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
///-------------------
|
|
|
/// @name Transactions
|
|
|
///-------------------
|