Ionic Framework : SQLite SELECT

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

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

ภาพประจำตัวสมาชิก
thatsawan
PHP VIP Members
PHP VIP Members
โพสต์: 28508
ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
ติดต่อ:

Ionic Framework : SQLite SELECT

โพสต์ที่ยังไม่ได้อ่าน โดย thatsawan »

โค้ด: เลือกทั้งหมด

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
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 67