1. #1
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default 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
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  2. #2
    Sencha User
    Join Date
    Nov 2011
    Location
    León, Spain
    Posts
    77
    Vote Rating
    3
    diesalher is on a distinguished road

      0  

    Default


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

    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();
    Maybe what i say makes no sense for some reason i dont know...but it seems to work.

  3. #3
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    @diesalher

    Yea its fine, there are couple of other ways also, so i haven't rounded upon one .

    Code:
    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);
        }
    Example

    Code:
    contactStore.load({params :{ name: '435'},query : 'select * from contacts_tables WHERE firstName = ?'});
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  4. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    81
    Vote Rating
    0
    sarah_77 is on a distinguished road

      0  

    Default


    Great!! But this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?

    Thanks

  5. #5
    Sencha User
    Join Date
    Nov 2011
    Location
    León, Spain
    Posts
    77
    Vote Rating
    3
    diesalher is on a distinguished road

      0  

    Default


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

    Code:
    Ext.create(model, {field1: data1,field2: data2}).save();
    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.

    Maybe i'm facing this in the wrong way, i'm still learning javascript and sencha,

    Thanks

  6. #6
    Sencha User
    Join Date
    Mar 2011
    Posts
    81
    Vote Rating
    0
    sarah_77 is on a distinguished road

      0  

    Default


    I don't know this point: this is a solution for manage SQLLite on PhoneGap with Sencha Touch 2.0?

    Thanks

  7. #7
    Sencha User
    Join Date
    Nov 2011
    Location
    León, Spain
    Posts
    77
    Vote Rating
    3
    diesalher is on a distinguished road

      0  

    Default


    Quote Originally Posted by sarah_77 View Post
    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.

  8. #8
    Sencha User
    Join Date
    Mar 2011
    Posts
    81
    Vote Rating
    0
    sarah_77 is on a distinguished road

      0  

    Default


    Great! So this is SQLLite solution that don't use HTML5 localstorage! It uses SQLLite way....Right?

    Thanks

  9. #9
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    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');}});

    Quote Originally Posted by diesalher View Post
    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..

    Code:
    Ext.create(model, {field1: data1,field2: data2}).save();
    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.

    Maybe i'm facing this in the wrong way, i'm still learning javascript and sencha,

    Thanks
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  10. #10
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    Yes it is using Sqlite Storage
    Quote Originally Posted by sarah_77 View Post
    Great! So this is SQLLite solution that don't use HTML5 localstorage! It uses SQLLite way....Right?

    Thanks
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi