If I have a javascipt object:
var person = new Object();
person.name = "newPerson";
person.occupation = "Programmer";
person.stateName = function(){
console.log(this.name);
};
Using the SQLite based Titanium.Database API, how can I store this object in a single field? The below is working fine:
var db = Titanium.Database.openFile(Titanium.Filesystem.getFile(
Titanium.Filesystem.getApplicationDataDirectory(),'myDatabase.db'));
db.execute("CREATE TABLE IF NOT EXISTS myTable (persons TEXT)");
I want to then store the object in a table field:
db.execute("INSERT INTO myTable (persons) VALUES(?)", JSON.stringify(person));
But the below is returned:
SQL Statement invalid or database missing
[21:55:35:300] [Titanium.Database.DB] [Error] Exception executing: INSERT INTO myTable
(person) VALUES(?), Error was: SQL Statement invalid or database missing