Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
orbitaloop opened this issue Mar 13, 2012 · 4 comments
Open

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

orbitaloop opened this issue Mar 13, 2012 · 4 comments

Comments

@orbitaloop
Copy link
Contributor

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);
    }
},
@ns-1m
Copy link

ns-1m commented Mar 17, 2012

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).

@brodycj
Copy link

brodycj commented Mar 21, 2012

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!

@brodycj
Copy link

brodycj commented Mar 27, 2012

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

@brodycj
Copy link

brodycj commented Apr 9, 2012

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants