Skip to content

The plugin API is not the same as the HTML5 WebSQL API #11

Description

@orbitaloop

It could be great to have the same API, in order to be able to use the app in a WebKit navigator.
Waiting for that, I wrote an adapter :

    _executeSqlBridge: function(tx, sql, params, dataHandler, errorHandler) {
    var self = this;
    if (typeof self.db.dbPath !== 'undefined') {
        //this is a native DB, the method signature is different:

        var sqlAndParams = [sql].concat(params);

        var cb = function(res) {
            //in WebSQL : result.rows.item(0)
            //in the phonegap plugin : res.rows[0]
            res.rows.item = function(i) {
                return this[i];
            };

            //the result callback hasn't the tx param
            dataHandler(tx, res);
        };

        tx.executeSql(sqlAndParams, cb, errorHandler);
    } else {
        //Standard WebSQL
        tx.executeSql(sql, params, dataHandler, errorHandler);
    }
},

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions