Note that there are some explanatory texts on larger screens.

plurals
  1. POTideSDK Database
    primarykey
    data
    text
    <p>I am new to TideSDK and am tring to get the local database working.</p> <p>First of all, is this the right thing to use? I expect the user will load the game, put some stuff (the local database) in without sending to the server, quit the game. Then come back to it later (even after turning off his pc or clearing his internet), load the game and all the local database stuff is still there, and then he can send it to the server then. (Should I be using a local file instead?)</p> <p>The error I am getting is with:</p> <pre class="lang-javascript prettyprint-override"><code>db.execute("INSERT INTO Games(id, player, timeText) VALUES(1, 1, 0)"); // Putting a zero time in </code></pre> <p>Its saying it is an incorrect sql statement or database does not exist.</p> <p>Ideally, I would also like to do the sqlite with prepared statements, but I wanted to start simpler.</p> <p>This is the mod of the HelloWorld example:</p> <p><a href="https://github.com/TideSDK/TideSDK-HelloWorld" rel="nofollow">https://github.com/TideSDK/TideSDK-HelloWorld</a></p> <p>My modded code:</p> <p>app.js</p> <pre class="lang-javascript prettyprint-override"><code>function DoSqlCall() { var lastTime; //Open the database first var db = Ti.Database.openFile(Ti.Filesystem.getFile( Ti.Filesystem.getApplicationDataDirectory(), 'customdatabase.db')); //Create a table and insert values into it db.execute("CREATE TABLE IF NOT EXISTS Games(id INTEGER, player INTEGER, timeText TEXT)"); alert("Hello 1"); var rows = db.execute("SELECT * FROM Games WHERE 'id' = 1 AND 'player' = 1"); if(rows.isValidRow()) { lastTime = rows.fieldByName('timeText'); alert("lastTime: " + lastTime.toString()); //rows.next(); } else { db.execute("INSERT INTO Games(id, player, timeText) VALUES(1, 1, 0)"); // Putting a zero time in alert("Put in zero time"); lastTime = 0; } //Release memory once you are done with the resultset and the database rows.close(); db.close(); }; // create and set menu var menu = Ti.UI.createMenu(), fileItem = Ti.UI.createMenuItem('File'), exitItem = fileItem.addItem('Exit', function() { if (confirm('Are you sure you want to quit?')) { Ti.App.exit(); } }); menu.appendItem(fileItem); Ti.UI.setMenu(menu); </code></pre> <p>index.html</p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Hello World&lt;/title&gt; &lt;style type="text/css"&gt; body {background: #fff;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello World&lt;/h1&gt; &lt;button id="m_Send" type="button" onclick="DoSqlCall()"&gt;Send&lt;/button&gt; &lt;script type="text/javascript" src="app.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload