當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript SQLite.executeSql方法代碼示例

本文整理匯總了TypeScript中ionic-native.SQLite.executeSql方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SQLite.executeSql方法的具體用法?TypeScript SQLite.executeSql怎麽用?TypeScript SQLite.executeSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ionic-native.SQLite的用法示例。


在下文中一共展示了SQLite.executeSql方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: tests

        }).then(() => {
          this.db.executeSql('CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY AUTOINCREMENT, name Text, user_id Text, date TIMESTAMP)', {}).then((data) =>{
            console.log("TESTS TABLE CREATED", JSON.stringify(data.res));
          }, (error) => {
            console.log("Error creating tests table", JSON.stringify(error.err));
          });

          this.db.executeSql('CREATE TABLE IF NOT EXISTS test_sections (id INTEGER PRIMARY KEY AUTOINCREMENT, section INTEGER, question TEXT, score TEXT, question_id INTEGER, test_id INTEGER, CONSTRAINT composite_id UNIQUE (section, question_id, test_id))', {}).then((data) =>{
            console.log("TEST SECTIONS TABLE CREATED", JSON.stringify(data.res));
          }, (error) => {
            console.log("Error creating tests table", JSON.stringify(error.err));
          });

          }, (err) => {
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:14,代碼來源:sqlite.ts

示例2: add

 public add() {
   this.database.executeSql("INSERT INTO user (firstname, lastname) VALUES (?, ?)", ['Alejandro', 'Romero']).then((data) => {
     console.log("INSERTED: " + JSON.stringify(data));
   }, (error) => {
     console.log("ERROR: " + JSON.stringify(error));
   });
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:7,代碼來源:home.ts

示例3: createTable

 createTable(){
   let sql = 'CREATE TABLE IF NOT EXISTS product(' +
       'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
       'type TEXT, ' +
       'quantity INTEGER, ' +
       'price TEXT, ' +
       'name TEXT)';
   return this.db.executeSql(sql, []);
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:9,代碼來源:service.ts

示例4: getAll

 getAll(){
   let query = 'SELECT * FROM product';
   return this.db.executeSql(query, [])
     .then(response => {
       let products = [];
       for (let index = 0; index < response.rows.length; index++) {
         products.push(response.rows.item(index));
       }
       return Promise.resolve(products);
     })
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:11,代碼來源:service.ts

示例5: refresh

 public refresh() {
   this.database.executeSql("SELECT * FROM user", {}).then((data) => {
     this.user = [];
     if(data.rows.length > 0) {
       for(var i = 0; i < data.rows.length; i++) {
         this.user.push({firstname: data.rows.item(i).firstname, lastname: data.rows.item(i).lastname});
       }
     }
   }, (error) => {
     console.log("ERROR: " + JSON.stringify(error));
   });
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:12,代碼來源:home.ts

示例6: deleteAnswers

 public deleteAnswers(id: number){
     let sql = 'DELETE FROM test_sections WHERE test_id = ?';
     return this.db.executeSql(sql, [id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:4,代碼來源:sqlite.ts

示例7: update

 // Update an existing note with a given ID
 public update(test: Test) {
     let sql = 'UPDATE test_sections SET score = ? WHERE section = ? AND question_id = ? AND test_id = ?';
     return this.db.executeSql(sql, [test.score, test.section, test.question_id, test.test_id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:5,代碼來源:sqlite.ts

示例8: add

 // Save a new note to the DB
 public add(test: Test) {
     let sql = 'INSERT OR IGNORE INTO test_sections (section, question, score, question_id, test_id) VALUES (?, ?, ?, ?, ?)';
     return this.db.executeSql(sql, [test.section, test.question, test.score, test.question_id, test.test_id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:5,代碼來源:sqlite.ts

示例9: getBySection

 // Get tests by section and test id
 public getBySection(section: number, id: number) {
     let sql = 'SELECT * FROM test_sections WHERE section = ? and test_id = ? ORDER BY section ASC';
     return this.db.executeSql(sql, [section, id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:5,代碼來源:sqlite.ts

示例10: getLast

  public getLast(test_id: number) {
    let sql = 'SELECT * FROM test_sections WHERE id = (SELECT MAX(id) FROM test_sections WHERE test_id = ?);';
    return this.db.executeSql(sql, [test_id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:4,代碼來源:sqlite.ts


注:本文中的ionic-native.SQLite.executeSql方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。