Hybrid View
-
19 Oct 2011 1:57 AM #1
SqliteProxy for ST2
SqliteProxy for ST2
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
-
12 Dec 2011 9:44 AM #2
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();
-
12 Dec 2011 8:48 PM #3
@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 = ?'});
-
3 Jan 2012 7:14 AM #4
Great!! But this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?
Thanks
-
3 Jan 2012 7:40 AM #5
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
-
4 Jan 2012 10:36 AM #6
I don't know this point: this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?
Thanks
-
6 Jan 2012 2:38 AM #7
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');}});
-
1 Mar 2013 6:24 AM #8
sqliteproxy for SQLIte database
sqliteproxy for SQLIte database
-
3 Mar 2013 12:35 AM #9
@mobileDev1600 , ST2 has its own proxy for SQLite databases, check the docs and here http://vadimpopa.com/sencha-touch-2-...xy-for-sqlite/
My blog: http://vadimpopa.com


Reply With Quote