Question

Application type: mobile. Titanium SDK: latest (3.0). Platform & version: Firefox 17.0.1. Host Operating System: Windows 7 x64. Logs:
From the error console in Firefox: TypeError: Ti.Database is undefined segment.

// create var for the currentWindow
var currentWin = Ti.UI.currentWindow;
var tableview = Titanium.UI.createTableView({
data:dataArray,
searchHidden :true
});
var dataArray = []; 
// set the data from the database to the array
function setData() { 

var db = Ti.Database.open('..\products.sqlite','products');

var rows = db.execute('SELECT DISTINCT category FROM products');

// create the array

while (rows.isValidRow())
{
 dataArray.push({title:'' + rows.fieldByName('category') });
 rows.next(); 
}

rows.close();
db.close();

// set the array to the tableView
tableview.setData(dataArray);

}
// create table view


tableview.addEventListener('click', function(e)
 {

var win = Ti.UI.createWindow({

 title:e.rowData.title
});

var prodCat = e.rowData.title;
win.prodCat = prodCat;
Ti.UI.currentTab.open(win);

});

// add the tableView to the current window
currentWin.add(tableview);

// call the setData function to attach the database results to the array
setData();  

How can i solve this problem?

Was it helpful?

Solution

Ti.Database module is not available for Mobile Web projects.

For simple client-side storage, you can use Ti.App.Properties. If you really need relational database, you'll have to implement a separate backend-service and access it using Ti.Network.HTTPClient.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top