Ionic Framework : SQLite SELECT

Mobile Application Developing- Android, iOS, Window Phone สอนเขียนโปรแกรมบนมือถือ ระบบปฏิบัติการต่าง แอนดรอยด์ ไอโอเอส วินโดโฟน สอนเขียนโปรแกรมบนมือถือ

Moderators: mindphp, ผู้ดูแลกระดาน

User avatar
thatsawan
PHP VIP Members
PHP VIP Members
Posts: 28071
Joined: 31/03/2014 10:02 am
Contact:

Ionic Framework : SQLite SELECT

Post by thatsawan »

Code: Select all

photoApp.controller('AccountCtrl', function ($scope, $cordovaDevice, $ionicPlatform, $cordovaSQLite) {
    // $scope.settings = {
    $scope.enableGps = true;
    $scope.id_row = 0;

    //$scope.select = function () {
    var query = "SELECT id,username, useGps,urlname FROM usersetting";
    $cordovaSQLite.execute(db, query).then(function (result) {
        alert(result.rows.item(0).id);
        $scope.id_row = result.rows.item(0).id;
        if (result.rows.length > 0) {
            for (var i = 0; i < result.rows.length; i++)
            {
                console.log("username : " + result.rows.item(i).username + " urlname : " + result.rows.item(i).urlname);
                alert("username : " + result.rows.item(i).username + " urlname : " + result.rows.item(i).urlname);
            }


            $scope.username = result.rows.item(0).username;

            if ($scope.username == '') {
                $scope.username = $cordovaDevice.getModel();
            }
            $scope.useGps = result.rows.item(0).useGps;
            $scope.urlname = result.rows.item(0).urlname;
            $scope.id = result.rows.item(0).id;

        } else {
            console.log("NO ROWS EXIST");
        }
    }, function (error) {
      
        console.error(error);
    });


}); 
  • Similar Topics
    Replies
    Views
    Last post

Return to “Mobile Application Developing- Android, iOS”

Who is online

Users browsing this forum: No registered users and 1 guest