Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Help with sqlite

$
0
0

Sorry.

This code works:

if(window.cordova) {
// App syntax
var db = $cordovaSQLite.openDB("myapp.db");
} else {
// Ionic serve syntax
var db = window.openDatabase("myapp.db", "1.0", "My app", -1);
}

$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS teste (name text)");

...

In the controller:

var query = "SELECT * FROM teste";

$cordovaSQLite.execute(db, query).then(function(res) {
if(res.rows.length > 0) {
$scope.teams = res.rows;
//console.log("SELECTED -> " + res.rows.item(0));
} else {
console.log("No results found");
}
}, function (err) {
console.error(err);
});

Occurrs an error at db reference.


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>