Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

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

      0  

    Arrow Ext.sql.SQLiteStore: load data from a database view

    Ext.sql.SQLiteStore: load data from a database view


    Hi!

    I am using Ext.sql.SQLiteStore in an Adobe AIR app. I want to retrieve my data from a view in the database (not from a table) specifying the view's name to the tableName property:

    Code:
    var grid = Ext.grid.GridPanel({
    	...
    	store: Ext.sql.SQLiteStore({
    		autoLoad: true,
    		dbFile: 'db/database.sqlite',
    		tableName: 'vfiles',
    		key: 'fle_id',
    		fields: [
    			...
    		]
    	});
    	...
    });
    My problem is, that I get an SQLError:
    'cannot modify 'vfiles' because it is a view', operation: 'execute', detailId: 2089
    Nevertheless the data is available in my grid.

    Does anyone know, how to turn this error off and how to use SQLiteStore with a database view properly?
    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

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

      0  

    Default


    I solved my problem by extending some relevant classes:

    Code:
    Ext.namespace('Ext.ux');
    
    Ext.override(Ext.sql.AirConnection, {
    	getView: function(name){
    		return new Ext.ux.SQLiteView(this, name);
    	}
    });
    
    Ext.ux.SQLiteView = Ext.extend(Ext.sql.Table, {
    	constructor: function(conn, name) {
    		this.conn = conn;
    		this.name = name;
    	},
    	update: Ext.emptyFn,
    	updateBy: Ext.emptyFn,
    	insert: Ext.emptyFn,
    	lookup: Ext.emptyFn,
    	exists: Ext.emptyFn,
    	save: Ext.emptyFn,
    	remove: Ext.emptyFn,
    	removyBy: Ext.emptyFn
    });
    
    Ext.ux.SQLiteProxy = Ext.extend(Ext.sql.Proxy, {
    	constructor: function(conn, table, store, readonly){
    	    Ext.sql.Proxy.superclass.constructor.call(this);
    	    this.conn = conn;
    	    this.table = table;
    	    this.store = store;
    	
    		if (readonly !== true) {
    			this.store.on('add', this.onAdd, this);
    			this.store.on('update', this.onUpdate, this);
    			this.store.on('remove', this.onRemove, this);
    		}
    	}
    });
    
    
    Ext.ux.SQLiteStore = Ext.extend(Ext.data.Store, {
        constructor: function(config) {
            config = config || {};
            config.reader = new Ext.data.JsonReader({
                id: config.key,
                fields: config.fields
            });
            
            if (!config.conn || config.dbFile) {
            	var conn = Ext.sql.Connection.getInstance();
            	conn.open(config.dbFile);
            } else var conn = config.conn;
            // Create the database table if it does
            // not exist
            if (!config.viewName) {
            	conn.createTable({
                		name: config.tableName,
                		key: config.key,
                		fields: config.reader.recordType.prototype.fields
            	});
            	var table = conn.getTable(config.tableName, config.key);
            } else var table = conn.getView(config.viewName);
            Ext.ux.SQLiteStore.superclass.constructor.call(this, config);
            this.proxy = new Ext.ux.SQLiteProxy(conn, table, this, false);        
        }
    });
    use it like this:

    Code:
    var ds = new Ext.ux.SQLiteStore({
    	conn: new Ext.sql.AirConnection({
    		db: 'myDbFile.sqlite'
    	}),
    	viewName: 'myView',
    	key: 'id',
    	fields: [
    		{name: 'id', type: 'int'},
    		...
    	]
    });
    or

    Code:
    var ds = new Ext.ux.SQLiteStore({
    	dbFile: 'myDbFile.sqlite',
    	tableName: 'myTable',
    	key: 'id',
    	fields: [
    		{name: 'id', type: 'int'},
    		...
    	]
    });
    You can specify either a view by setting the property "viewName" or a table with "tableName".
    Use views for queries only!
    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
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    Makana,

    thanks for sharing this code i am just starting to learn SQLite and how AIR and Ext work with it. I was actually experiencing a very similar issue and I think your code can fix it =D Gonna try it later.

    BTW, LOVE your signature and I want to steal it :P

Thread Participants: 1