insert update delete select operation in ionic…plz help me.
What are you trying to achieve? Please provide some more information, only then we can help you.
The architecture of software you´re trying to achieve is this:
- Ionic Application communicates via angular $http-Service with a web service (written in PHP or nodeJS)
- Web-Service communicates with the database (insert, update…) and sends data via JSON back to Ionic application
Create table:
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS DeviceInfoTable (id integer primary key, Setting text, Value text)");
Insert
$scope.insertDBSYNC = function(){
$ionicPlatform.ready(function() {
var db = $cordovaSQLite.openDB({ name: app.dbName, bgType: 1 });
var query = "INSERT INTO DeviceInfoTable(Setting,Value) VALUES(?,?)";
$cordovaSQLite.execute(db,query,['DBCreated','YES']).then(function(r){
app.Logger("DeviceInfoTable id ->" + r.insertId);
},function(e){
app.Logger(e);
})
})};
select
$scope.selectDBSYNC = function(){
$ionicPlatform.ready(function() {
var db = $cordovaSQLite.openDB({ name: app.dbName, bgType: 1 });
var query = "SELECT Value from DeviceInfoTable WHERE Setting = ?";
$cordovaSQLite.execute(db, query, ["DBCreated"]).then(function(r) {
app.Logger("Select id ->" + r.rows.item(0).Value);
$scope.DBSynced = r.rows.item(0).Value;
}, function(e) {
app.Logger(e);
})
}) };