1. #1
    Sencha User
    Join Date
    Oct 2009
    Posts
    33
    Vote Rating
    0
    wwwjsx is on a distinguished road

      0  

    Default SQLIteStore LEFT JOIN and add new fields to select

    SQLIteStore LEFT JOIN and add new fields to select


    Hi !

    this my store:

    PHP Code:
    this.store = new Ext.data.SQLiteStore ({
                
    dbFile      'data/unitech.db',
                
    tableName   Unitech.Tables.Product,
                
    baseParams  : { start0limitthis.pageSize },
                
    idProperty  'id',
                
    autoLoad    true,
                
    remoteSort  true,
                
    sortInfo    : { field'date_added'direction'DESC' },
                
    fields      : [
                    { 
    type'int',      name'id' },
                    { 
    type'string',   name'barcode' },
                    { 
    type'string',   name'name' },
                    { 
    type'int',      name'category_id' },
                    { 
    type'float',    name'price' },
                    { 
    type'int',      name'unit' },
                    { 
    type'int',      name'date_added' },
                    { 
    type'int',      name'date_modified'  },
                    { 
    type'int',      name'total' },
                    { 
    type'int',      name'available' }
                ],
            }); 
    How can I add LEFT JOIN and new columns to SQL.

    Thanks

  2. #2
    Sencha User makana's Avatar
    Join Date
    Apr 2008
    Location
    Dresden, Germany
    Posts
    527
    Vote Rating
    19
    makana has a spectacular aura about makana has a spectacular aura about

      0  

    Default


    Create a view and use it as tableName.
    Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)

    Enhanced ExtJS adapter for Adobe AIR

  3. #3
    Sencha User
    Join Date
    Oct 2009
    Posts
    33
    Vote Rating
    0
    wwwjsx is on a distinguished road

      0  

    Default


    Can you show me an example ? I am newbe.

    Thank you very much!

  4. #4
    Sencha User makana's Avatar
    Join Date
    Apr 2008
    Location
    Dresden, Germany
    Posts
    527
    Vote Rating
    19
    makana has a spectacular aura about makana has a spectacular aura about

      0  

    Default


    Hi!

    Use a database management tool, like the SQLiteManager addon for firefox, and open your database with it.
    Then create a view like:
    Code:
    CREATE VIEW myView
    AS
    SELECT t1.field1, t1.field2, t2.field3, t2.field4
        FROM myTable1 t1
        LEFT JOIN myTable2 t2
            ON t1.foreignKeyToT2Column = t2.primaryKeyColumn
    and apply the view's name (here "myView") to the tableName config option of the store:
    Code:
    this.store = new Ext.data.SQLiteStore ({
                dbFile      : 'data/unitech.db',
                tableName   : Unitech.Tables.Product,
                tableName   : 'myView',
                baseParams  : { start: 0, limit: this.pageSize },
                idProperty  : 'id',
                autoLoad    : true,
                remoteSort  : true,
                sortInfo    : { field: 'date_added', direction: 'DESC' },
                fields      : [
                    { type: 'int',      name: 'id' },
                    { type: 'string',   name: 'barcode' },
                    { type: 'string',   name: 'name' },
                    { type: 'int',      name: 'category_id' },
                    { type: 'float',    name: 'price' },
                    { type: 'int',      name: 'unit' },
                    { type: 'int',      name: 'date_added' },
                    { type: 'int',      name: 'date_modified'  },
                    { type: 'int',      name: 'total' },
                    { type: 'int',      name: 'available' }
                ],
            });
    You can then use the view to make reading requests to the database via the store.
    If you want to do insert, update or delete operations on the store, too, you have to create triggers on your view. E.g.
    Code:
    CREATE TRIGGER myViewTriggerInsert
    INSTEAD OF INSERT ON myView
    FOR EACH ROW
    BEGIN
        INSERT OR REPLACE INTO myTable2 (field3, field4) VALUES (new.field3, new.field4);
        INSERT INTO myTable1 (field1, field2, foreignKeyToT2Column) VALUES (new.field1, new.field2, (SELECT primaryKeyColumn FROM myTable2 WHERE field3 = new.field3 AND field4 = new.field4));
    END
    See http://www.sqlite.org/lang_createtrigger.html for more information.

    Cheers,
    makana
    Programming today is a race between software engineers striving to build bigger and better іdiot-proof programs, and the universe striving to produce bigger and better idiots. So far, the universe is winning. (Rick Cook)

    Enhanced ExtJS adapter for Adobe AIR

Similar Threads

  1. Rowexp + json, left outer join
    By RedJane in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 10 Dec 2009, 7:57 AM
  2. [Solved]Left align form fields
    By yuiman in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Feb 2009, 4:16 PM
  3. How to use Select with inner join in Short Colunm Grid
    By Rafael in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 19 Dec 2008, 8:58 AM

Thread Participants: 1

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