1. #21
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    498
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Thanks eryx, I'm glad it's useful to others!

    The Sencha Command issue is now fixed. It's not the world's prettiest fix, but it works. NB: the fix is in the demo files, NOT the proxy itself. Specifically look at the model definition and the util class.

    https://github.com/shepsii/SQLite-Proxy-ST2

    I changed the Ext.Loader.setPath call and removed the source within the demo directory so make sure your setPath call is pointing to where the sqlite directory is, relative to app.js. Ext.Loader needs this during testing to load in the files and sencha command needs it to grab the contents of the sqlite files to put them into the single app.js file for production or testing builds.


    * 2012/05/14 SENCHA COMMAND COMPATIBILITY *
    An issue with the demo app not working when it's been built into production or testing (ie, into a single js file) has been sorted.

    It's a fix that works; for some reason when Sencha is in a single file the models will be initiated and their proxies created BEFORE the onReady method of the Ext.Application call is executed. In a pre-build, multi-file development environment, the model calls are after.

    NB: I have also changed the Ext.Loader.SetPath call in the app.js of the demo so the source code for the sqliteproxy is only included once in the root of the repository (rather than twice - ie, it's no longer copied in the demo directory).

  2. #22
    Sencha User
    Join Date
    Mar 2012
    Posts
    28
    Vote Rating
    0
    gcw07 is on a distinguished road

      0  

    Default


    shepsii Thank you for the production build fix. Wonder why the development build loads things differently from the production build. Either way thank you.

  3. #23
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    498
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    No worries! I think it's all to do with everything being in one file, and having the contents of app.js at the bottom... javascript hits and executes the model code before the Ext.Application can call the onReady method. Annoying! Different variants of that issue have hit different areas of my code before...

  4. #24
    Sencha User
    Join Date
    Sep 2011
    Posts
    23
    Vote Rating
    0
    eryx is on a distinguished road

      0  

    Default Question

    Question


    Hi there it's me again and I have a question.

    In Thomas Alexander plugin I was able to do this

    PHP Code:
    var storeProxy app.stores.NewsStore.getProxy();
    storeProxy.queryDB(storeProxy.dbConfig.dbConnsqlQuery); 
    So I made an Ajax request got some xml data parsed it and prepared an SQL Statement, then I simply put it into the db like above.

    Getting the proxy seems to be the same or atleast it works

    PHP Code:
    store Ext.getStore('News');
    proxy store.getProxy(); 
    So getting the store and then the proxy seems to be no problem

    My question now how would I go about inserting this into my db. Is there a function where I can do this over the plugin, or do I need to write this by myself?

    Thanks for your time!

    Greetings eryx

  5. #25
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    498
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Hi Eryx,

    TA's proxy's function was called queryDB - while that's true, it was doing it within a transaction so I renamed the function transactionDB, and changed it to accept multiple queries.

    Also, it's not best practice to do things in this way, because if I change the way the proxy works internally in the future, perhaps to fix a bug, you might be stuck with the buggy version if your SQL statement is not compatible with the new schemas the proxy creates.

    Better practice is to load the data into a store using an XML proxy, and then copy across the data to another store with the sqlite proxy (or.... set the original store's proxy to an sqlite proxy, and then set all records to dirty or phantom and resave).

    If you still want to go ahead with the way you're doing things now, you need to use the transactionDB method of the proxy. This accepts the following parameters:
    dbConn - just use proxy.getDb() (in a future version, I really should lose this parameter as it's not necessary)
    queries - an array of functions that accept tx as a parameter and execute queries
    successcallback - called on transaction success
    errorcallback - called on transaction error
    callback - always called at end of transaction (I don't advise using this as it's currently in the incorrect place in the code, no-one said this was a final release yet haha!)

    So here's an example call:

    Code:
    storeProxy.transactionDB(storeProxy.getDb(), [
    function(tx) {
      tx.executeSql(sqlQueryString, parameterArray, Ext.emptyFn, Ext.emptyFn);
    }
    ],
    function() { console.log('success!'); },
    function() { console.log('error!'); }
    );
    You might for instance then use the onsuccess callback to load a store using the data you've just inserted into the database.

  6. #26
    Sencha User
    Join Date
    Sep 2011
    Posts
    23
    Vote Rating
    0
    eryx is on a distinguished road

      0  

    Default Re

    Re


    Hi thanks for your fast and extensive reply. That really helps me. I think I will try the approach with the XML Proxy. I haven't even tried that so I need to see if I'm able to do so ^^.

    For now I created a small function for myself. It's almost the same as your transactionDB function.

    PHP Code:
    Ext.define('swissunihockey.handler.Sqlite', {
        
    insert: function (dbsqlcallback) {
            var 
    me this;//saving scope
            
    db.transaction(function (tx) {
                
    //do not add () to me.sqlitErrorHandler or it will be
                //executed immediately when parsed
                
    tx.executeSql(sql, [], callbackme.sqliteErrorHandler);
            });
        },
        
    /**
         * if you return true this means its a fatal error and the transaction gets aborted
         * return false to ignore the error and finish the transaction anyway
         * @param {Object} transaction-object
         * @param {Object}, error-object
         * @return {Boolean}
         */
        
    throwDbError: function (transactionerror) {
            
    console.log('Error! Errormessage was ' error.message ' (Code ' error.code ')');
            return 
    true;
        }
    }); 
    Thanks for your nice answer and have a nice day

    eryx

  7. #27
    Sencha User
    Join Date
    Sep 2011
    Posts
    23
    Vote Rating
    0
    eryx is on a distinguished road

      0  

    Default One last question

    One last question


    Hi again I hope I don't bother you to much but I have one last question ^^

    I couldn't work out the whole xml proxy part and I'm trying to use the functions in your plugin now.
    But I'm really new to Sencha Touch 2 and somehow I can't wrap my head around this.

    PHP Code:
    Ext.define('swissunihockey.handler.Parser', {
        
    //extend: 'swissunihockey.handler.Sqlite',
        //extend: 'Sqlite.data.proxy.SqliteStorage',
        
        
    newsparser: function (xmlDoc) {

            var 
    header 0,
                
    sqlQuery '',
                
    0,
                
    el,
                
    news xmlDoc.getElementsByTagName('item');

            
    sqlQuery 'INSERT INTO news(title, link, description, pubDate, imagebig, imagesmall)';

            for (
    0news.lengthi++) {
                
    el news[i];
                
    sqlQuery += header++ === "SELECT " " UNION SELECT ";
                
    encodeURIComponent(el.getElementsByTagName('title')[0].textContent);
                
    sqlQuery += '\'' encodeURIComponent(el.getElementsByTagName('title')[0].textContent) + '\' AS \"title\", ' +
                    
    '\'' encodeURIComponent(el.getElementsByTagName('link')[0].textContent) + '\' AS \"link\", ' +
                    
    '\'' encodeURIComponent(el.getElementsByTagName('description')[0].textContent) + '\' AS \"description\", ' +
                    
    '\'' encodeURIComponent(el.getElementsByTagName('pubDate')[0].textContent) + '\' AS \"pubDate\", ' +
                    
    '\'' encodeURIComponent(el.getElementsByTagName('bildgross')[0].textContent) + '\' AS \"imagebig\", ' +
                    
    '\'' encodeURIComponent(el.getElementsByTagName('bildklein')[0].textContent) + '\' AS \"imagesmall\"';
            }
            
    //console.log(sqlQuery);
            
    a  sqlQuery;
            
    store Ext.getStore('News');
            
    proxy store.getProxy();
        }
    }); 
    This is my current class but I somehow don't get how I can use a function from the plugin from here inside this class. I tried extending from the sqlite plugin but then I need to pass a config object or I get the error:
    TypeError: Cannot read property 'dbConn' of null
    I Hope you can help me on that point :/

    Greetings eryx

  8. #28
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    498
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Ok, here's the deal... the way you're doing it right now is ugly and not best practice. I'm more than happy to help doing it the best way I can think of (loading using xml parser). Do you want to post your model config and a sample XML? Also, do you have control of the XML file - ie, can you change its contents or is it fixed as it is?

  9. #29
    Sencha User
    Join Date
    Sep 2011
    Posts
    23
    Vote Rating
    0
    eryx is on a distinguished road

      0  

    Default


    Ok then let's do it the right way!

    Here is my model at the moment

    PHP Code:
    Ext.define('swissunihockey.model.News', {
        
    extend'Ext.data.Model',

        
    config: {
            
    fields: [
                {
                    
    name'id',// Every model must start with an id of type int
                    
    type'int'
                
    }, {
                    
    name'title',
                    
    type'string'
                
    }, {
                    
    name'link',
                    
    type'string'
                
    }, {
                    
    name'description',
                    
    type'string',
                }, {
                    
    name'pubDate',
                    
    type'int'
                
    }, {
                    
    name'imagebig',
                    
    type'string'
                
    }, {
                    
    name'imagesmall',
                    
    type'string'
                
    }
            ],
            
    proxy: {
                
    type'sqlitestorage',
                
    dbConfig: {
                    
    tablename'news',
                    
    dbConnswissunihockey.util.InitSQLite.getConnection()
                }
            }
        }
    }); 
    And an example how my xml looks like. Sadly I don't have control over it. I can't change it.

    PHP Code:
    <xml><item><title>WM-Gold für Finnland</title><link>http://www.spox.ch/spx-rss-redirect.aspx?newsid=225734&navi=755&sprache=D&rnr=110</link><description><=!=[=C=D=A=T=A=[<p class="lead"><strong>Die Schweizer U19-Damen-Nationalmannschaft unterliegt im WM-Finale Finnland mit 1:3 und muss sich mit der Silbermedaille begnügen.</strong></p>  <div class="image_right_floated">  <dl style="width: 228px;" class="image right_floated">  <dt> <str]=]=><=!=[=C=D=A=T=A=[ong>Finnland sichert sich WM-Gold</strong></dt>  </dl>  </div>  <p>Wie im Halbfinale gegen Tschechien gingen die Schweizer U19-Frauen mit einer sehr defensiven Einstellung ins WM-Finale. Diesmal ging die Abwarte-Taktik aber nicht auf. In der 16. Minute mussten die Schweizerinnen den ersten Gegentreffer hinnehmen, bei Spielhälfte innert zwei Minuten zwei weitere. Das 0:3 war dann eine zu grosse Hypothek, auch wenn die Schweiz im Schlussdrittel mit Vehemenz den Anschlusstreffer suchte. Erst in der 59. Minute traf Fabienne Walther zum 1:3. Zu mehr reichte es nicht. Trotzdem fanden die Schweizerinnen rasch nach Spielschluss ihr Lachen wieder. "Wir haben Silber gewonnen", sagte auch Co-Nationaltrainer Bernhard Nussbaum. Von fünf Partien verlor die Schweiz in Nitra nur eine. Finnland stellte die ausgeglichenste Equipe und gewann verdient den Weltmeistertitel. Der alte Weltmeister Schweden musste mit dem dritten Platz vorlieb nehmen. Mit Simona Stock (Tor) und Nina Bärtschi (Sturm) fanden auch zwei Schweizerinnen Aufnahme im All-Star-Team des Turniers.</p>  <h3>Rückkehr am Sonntag</h3>  <p>Die Schweizerinnen treten morgen Sonntag ihre Heimreise an und treffen um 11.30 Uhr am Flughafen Zürich (Terminal 1) ein. Selbstverständlich freuen sie sich über einen herzhaften Empfang!</p>  <div class="youtube"> </div>  <h3>Schweiz-Finnland: 1:3 (0:1,0:2,1:0)</h3>  <p>Tore: 15:46 Pevra Juulia (Manninen Laura) 0:1, 24:53 Wickman Mira (Arkkina Hillevi) 0:2, 26:05 Hietanen Senni (Eskelinen Silja) 0:3, 58:51 Walther Fabienne (Bärtschi Nina) 1:3 .</p>  <h3>Schweiz:</h3>  <p>Stock Simona; Liechti Lisa, Decurtins Prisca; Leu Claudia, Handl Nadine; Reinhard Nadja, Zellweger Rahel; Sturzenegger Sina; Krebs Corina, Walther Fabienne, Bärtschi Nina; Gämperli Andrea, Huber Nicole, Meer Vera; Luck Kassandra, Marendaz Laura, Spichiger Nathalie; Schibli Gisela, Ludwig Ramona.</p>]=]=></description><pubDate>1336379280000</pubDate><bildgross>http://www.spox.ch/cgi-bin/mobilescout/si/2012/05/crop-310-225734-or.jpg</bildgross><bildklein>http://www.spox.ch/cgi-bin/mobilescout/si/2012/05/crop-115-225734-or.jpg</bildklein></item>
    </xml

    Hm I see the xml code is unreadable.
    This is the structure

    <xml>
    <item>
    <titel></title>
    <link></link>
    <description></description>
    <pubDate></pubDate>
    <bildgross></bildgross>
    <bildklein></bildklein>
    </item>
    </xml>

  10. #30
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    498
    Vote Rating
    51
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Ok so trying to work this out myself, but the first step will be to get the data loaded using an XML proxy and reader.

    http://docs.sencha.com/touch/2-0/#!/api/Ext.data.reader.Xml

    I
    note that your sencha touch field names are different from the XML attribute names. I believe we can use mapping to adapt this on the field configurations, but I've not done this before nor have I seen another example! Here's the link:

    http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Field


    I
    've not done this myself before, but it looks like you just need to set the mapping attribute of each field to a query that will match it in the dom. May need some trial and error here! Likely you need to have something like this for each field that is different on the model:

    Code:
    { name: 'imagebig', type: 'string', mapping: 'bildgross' }
    I'm not sure if that exactly will work, look into the query format you need for the 'bildgross' string...

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