Get the App
SLTechnology News&Howtos  ›  Development  › 

How to operate the database through phonegap

Shulou Source: shulou.com Published: 2022-06-03 12:14:24 11月15日 Update

This article mainly introduces how to operate the database through phonegap, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Examples are as follows:

Database Example document.addEventListener ("deviceready", onDeviceReady, false); function onDeviceReady () {var db=window.openDatabase ("Test", "1.0", "Test", 200000); db.transaction (populateDB,errorDB,successDB) } / / initialize database data function populateDB (tx) {tx.executeSql ('DROP TABLE IF EXISTS test1'); tx.executeSql (' CREATE TABLE IF NOT EXISTS test1 (id unique,name)'); tx.executeSql ('INSERT INTO test1 (id,name) VALUES (1, "Tony")) Tx.executeSql ('INSERT INTO test1 (id,name) VALUES (2, "Bill")); tx.executeSql (' INSERT INTO test1 (id,name) VALUES (3, "Tony"));} / / query method function queryDB (tx) {tx.executeSql ('SELECT * FROM test1', [], querySuccess,errorDB) } / / callback for successful query function querySuccess (tx,results) {var len=results.rows.length; var status=document.getElementById ("status"); var string = "Rows:" + len+ "; for (var iTuno Teti

Tags: Data articles databases success queries values interests at the same time examples methods more friends knowledge editing industry information information channels channels references learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Xiaomi Redmi Shulou Technology Shulou Information