简体   繁体   中英

cordova sqlite delete not working

I am trying to delete a particular id from my SQLite DB after successful post inside an interval, but it is not working, although it prints "success" in the console.

       $interval(function(){
       var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
                 var query = "SELECT * FROM allcaseimage";
                  $cordovaSQLite.execute(db, query).then(function (result) {
                     var myRowsIds = [];

                     var len = result.rows.length;
                     for (var i=0; i<len; i++){
                        $scope.records_id =  result.rows.item(i).records_id;
                        $scope.caseimage =  result.rows.item(i).caseimage;

                    }

                      var request = $http({
                        method: "post",
                        url: "http://45.55.19.50/mobile/api/savecasepic.php",
                        data: {
                            records_id: $scope.records_id,
                            image : $scope.caseimage
                        },
                        headers: { 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8' }
                    });

                       request.success(function (data) {

                           var db = $cordovaSQLite.openDB({ name: "allimage.db", location: 'default', bgType: 1 });
                           var query = "DELETE FROM allcaseimage where records_id = '"+$scope.records_id+"'";
                                $cordovaSQLite.execute(db, query, []).then(function(res) {
                                  //success
                                }, function (err) {
                                    console.error(err);
                                });

                         })


                  }, function (error) {
                    $scope.showAlert('data error');
                  })
            },20000);

console screenshot

您可能需要提交事务。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM