|
|
@@ -245,9 +245,11 @@ typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
/// @name Perform updates
|
|
|
///----------------------
|
|
|
|
|
|
-/** 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.
|
|
|
|
|
|
@@ -281,14 +283,16 @@ typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
@see lastErrorCode
|
|
|
@see lastErrorMessage
|
|
|
@see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
|
|
|
+
|
|
|
+ @note This technique supports the use of `?` placeholders in the SQL, automatically binding any supplied value parameters to those placeholders. This approach is more robust than techniques that entail using `stringWithFormat` to manually build SQL statements, which can be problematic if the values happened to include any characters that needed to be quoted.
|
|
|
*/
|
|
|
|
|
|
- (BOOL)executeUpdate:(NSString*)sql, ...;
|
|
|
|
|
|
-/** Execute update statement
|
|
|
+/** 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 [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL. Do not use `?` placeholders in the SQL if you use this method.
|
|
|
|
|
|
- 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.
|
|
|
-
|
|
|
@param format The SQL to be performed, with `printf`-style escape sequences.
|
|
|
|
|
|
@param ... Optional parameters to bind to use in conjunction with the `printf`-style escape sequences in the SQL statement.
|
|
|
@@ -305,9 +309,11 @@ typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
|
|
|
- (BOOL)executeUpdateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
|
|
|
|
|
|
-/** Execute update statement
|
|
|
+/** Execute single update statement
|
|
|
|
|
|
- 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.
|
|
|
+ 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.
|
|
|
|
|
|
@@ -322,9 +328,11 @@ typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
|
|
|
- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
|
|
|
|
|
|
-/** Execute update statement
|
|
|
+/** 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 [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
|
|
|
|
|
|
- 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.
|
|
|
+ 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.
|
|
|
|
|
|
@@ -340,8 +348,21 @@ typedef int(^ExecuteBulkSQLCallbackBlock)(NSDictionary *resultsDictionary);
|
|
|
- (BOOL)executeUpdate:(NSString*)sql withParameterDictionary:(NSDictionary *)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 [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
|
|
|
+
|
|
|
+ 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 args A `va_list` of arguments.
|
|
|
+
|
|
|
+ @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
|
|
|
+ */
|
|
|
|
|
|
-// Documentation forthcoming.
|
|
|
- (BOOL)executeUpdate:(NSString*)sql withVAList: (va_list)args;
|
|
|
|
|
|
/** Execute multiple SQL statements
|