Hi,
I have ported sqliteproxy to work with ST2.
You can find previous thread
http://www.sencha.com/forum/showthre...Proxy&p=661960
Updated Code can be found under .
https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy
Printable View
Hi,
I have ported sqliteproxy to work with ST2.
You can find previous thread
http://www.sencha.com/forum/showthre...Proxy&p=661960
Updated Code can be found under .
https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy
Hi.
I'm a bit new in sencha and javascript so maybe this makes no sense...
i've modified your proxy to be able to use params in the query..
Code:
read: function(operation, callback, scope) {
var me = this;
var sql = me.dbConfig.dbQuery || 'SELECT * FROM ' + me.dbConfig.tablename + '';
var params, onSucess, onError;
params = me.dbConfig.params ? me.dbConfig.params : [];
onSucess = function(tx, results) {
me.applyDataToModel(tx, results, operation, callback, scope);
};
onError = function(tx, err) {
me.throwDbError(tx, err);
};
me.queryDB(me.dbConfig.dbConn, sql, onSucess, onError, params);
}
then, in order to load the store i do somethig like...
Maybe what i say makes no sense for some reason i dont know...but it seems to work.Code:
var qry = 'SELECT * FROM Test where field 1 = ? and field2 = ?';
var params = [ 'P1','P2'];
store.getProxy().dbConfig.dbQuery = qry;
store.getProxy().dbConfig.params = params;
store.load();
@diesalher
Yea its fine, there are couple of other ways also, so i haven't rounded upon one :).
ExampleCode:read: function(operation, callback, scope) {
var param_arr = [];
Ext.iterate(operation.params,function(a,i){
param_arr.push(i);
});
var thisProxy = this;
var sql = operation.query || thisProxy.dbConfig.dbQuery || 'SELECT * FROM '+thisProxy.dbConfig.tablename+'';
var params, onSucess, onError;
onSucess = function(tx, results) {
thisProxy.applyDataToModel(tx, results, operation, callback, scope);
};
onError = function(tx, err) {
thisProxy.throwDbError(tx, err);
};
thisProxy.queryDB(thisProxy.dbConfig.dbConn, sql, onSucess, onError,param_arr);
}
Code:contactStore.load({params :{ name: '435'},query : 'select * from contacts_tables WHERE firstName = ?'});
Great!! But this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?
Thanks
I've been using sqliteproxy with good results in sencha 2.0
i have a question
I'm doing a function who loads data in several tables . Is there a way to do this inserts in a batch to load the stores when in finish the complete batch?
now, to insert a record im doing something like..
but it seems to be asynchronous so if i insert 1000 records, i don't know if there is a way to wait till inserted to do a store.load() again.Code:Ext.create(model, {field1: data1,field2: data2}).save();
Maybe i'm facing this in the wrong way, i'm still learning javascript and sencha,
Thanks
I don't know this point: this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?
Thanks
This is a proxy which uses the sqlite web sql database of the browser as backend for Sencha touch. Works with Phonegap or without it. The Author can give you more details, as i'm pretty new using it, but basically i'm using to store my app data in sqlite database.
Great! So this is SQLLite solution that don't use HTML5 localstorage! It uses SQLLite way....Right?
Thanks
Sqlite query operation in browsers are asynchronous in nature, So i'm not sure how to handle callback of batch insertion. But you can implement callback in save function
Go through http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Model which does have usage of success callback in save function
Code:user.save({success: function() {console.log('The User was updated');}});