mirror of
https://github.com/moparisthebest/PhoneGap-SQLitePlugin-Android
synced 2024-11-25 18:12:16 -05:00
Fix for #18 for INSERT statement ONLY for Simple-DroidGap-test
This commit is contained in:
parent
67cd416c70
commit
be6834720b
@ -77,6 +77,12 @@ DDB.prototype.completeQuery = function(id, data) {
|
||||
var r = new DDB_Result();
|
||||
r.rows.resultSet = data;
|
||||
r.rows.length = data.length;
|
||||
if (!!data.length && data.length > 0 && !!data[0].insertId) {
|
||||
r.insertId = data[0].insertId;
|
||||
}
|
||||
if (!!data.length && data.length > 0 && !!data[0].rowsAffected) {
|
||||
r.rowsAffected = data[0].rowsAffected;
|
||||
}
|
||||
try {
|
||||
if (typeof query.successCallback === 'function') {
|
||||
query.successCallback(query.tx, r);
|
||||
|
@ -166,8 +166,15 @@ public class SQLitePlugin extends Plugin {
|
||||
* Transaction id
|
||||
*/
|
||||
public void executeSql(String query, String[] params, String tx_id) {
|
||||
String cmd = query.toLowerCase();
|
||||
|
||||
try {
|
||||
if (isDDL(query)) {
|
||||
if (cmd.startsWith("insert")) {
|
||||
SQLiteStatement myStatement = this.myDb.compileStatement(query);
|
||||
long insertId = myStatement.executeInsert();
|
||||
this.sendJavascript("dddb.completeQuery('" + tx_id + "', [{'insertId':'" + insertId +
|
||||
"', 'rowsAffected':'1'}]);");
|
||||
} else if (isDDL(query)) {
|
||||
this.myDb.execSQL(query);
|
||||
this.sendJavascript("dddb.completeQuery('" + tx_id + "', '');");
|
||||
}
|
||||
@ -240,9 +247,7 @@ public class SQLitePlugin extends Plugin {
|
||||
}
|
||||
|
||||
// Let JavaScript know that there are no more rows
|
||||
this.sendJavascript("dddb.completeQuery('" + tx_id + "', " + result
|
||||
+ ");");
|
||||
|
||||
this.sendJavascript("dddb.completeQuery('" + tx_id + "', " + result + ");");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user