镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Open

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

  1. ns-1m commented on Mar 17, 2012

    @ns-1m

    Here is an info, Introducing Web SQL Databases

    http://html5doctor.com/introducing-web-sql-databases/

    I think this is useful for us who is trying to use this plugin.

    I am going to use PhoneGap again because this plugin (I am using QuickConnect with Sqlite/Spatialite).

  2. brody2consult commented on Mar 21, 2012

    @brody2consult
    Contributor

    Yes it would be nice if the db object returned by new PGSQLitePlugin(db_name) would follow almost the same API as the HTML5 WebSQL API. Nice link from @ns-1m!

  3. brody2consult commented on Mar 27, 2012

    @brody2consult
    Contributor

    I just issued pull request #24 to propose a change to the API. I think it should wait for the Cordova version.

  4. brody2consult commented on Apr 9, 2012

    @brody2consult
    Contributor

    Please take a look at https://github.com/chbrody/Cordova-SQLitePlugin/ I have made both an Android (DroidGap) version and made a number of API improvements. For example, instead of new SQLitePlugin() use sqlitePlugin.openDatabase() (both iOS and Android versions). There is a common Lawnchair adapter for both Android and iOS versions, along with a working Lawnchair test suite. I want to do some cleanups and then issue an official pull request.

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