Hi,
I am working on an app that uses SQLite db using Titanium Appcelerator Alloy framework.
Here's one of my models: customer_order_queue.js
exports.definition = { config: { "columns": { "QueueId":"INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE", "CustomerId":"INTEGER", "BasketData":"TEXT", // JSON Encoded Sku, Name, Qty, Price Array "OrderCurrency":"TEXT", "PaymentMethod":"TEXT", "ShippingMethod":"TEXT", "ShippingMethodTitle":"TEXT", "Subtotal":"REAL", "ShippingAmount":"REAL", "TaxAmount":"REAL", "CurrencyRate":"REAL", "TaxRate":"REAL", "GrandTotal":"REAL", "Status":"TEXT", // Pending OR Error OR Synced "LastError":"TEXT" }, "adapter": { "type":"sql", "collection_name":"customer_order_queues", "db_name":"myApp", "idAttribute":"QueueId" } }, extendModel : function(Model) { _.extend(Model.prototype, { }); return Model; }, extendCollection : function(Collection) { _.extend(Collection.prototype, { executeQuery : function(sqlStatement) { db = Ti.Database.open(this.config.adapter.db_name); db.execute(sqlStatement); db.close(); db = null; this.trigger('sync'); }, deleteAll : function() { db = Ti.Database.open(this.config.adapter.db_name); db.execute('DELETE FROM '+ this.config.adapter.collection_name); db.execute('DELETE FROM sqlite_sequence where name = \''+ this.config.adapter.collection_name +'\''); db.close(); db = null; this.trigger('sync'); } }); return Collection; } };I had someone test the app thoroughly and they ended up getting an application error randomly, which reads:
> invalid SQL Statement at Customer_order_queue.js (line 1)
Can anyone see anything wrong with this model?
Anyway, my question was, is it possible to have some sort of global error logging for all SQL errors? So I can see when SQL errors occurred, the last statement and the error message?