HTML5 web SQL dynamically creates database tables

Source: Internet
Author: User

HTML5 web SQL dynamically creates database tables

 

SmcsServices. service ('visitinstitutioncacheservice ', [' $ rootScope ',' $ http', 'baseurl', 'cesceservice ', function ($ rootScope, $ http, BaseURL, DataSourceService) {var service = {synVisit: function (synvtdatetime) {$ http ({method: 'post', cache: false, url: BaseURL + 'syscommoncodetransform/findVisitInstitution. do ', params: {datetime: synvtdatetime }}). success (function (response, status, headers, config) {try {var obj = response. visitInstitution; var synobj = response. synvisitlist; // optimized for dynamic table var objstr = JSON after test and development. stringify (obj [0]); console. log (obj [0] ===+ objstr); var objjson = JSON. parse (objstr); for (var key in objjson) {console. log (the key of objjson is ===+ key);} // after testing and development, optimize the dynamic creation of the table var db = DataSourceService. getConnection (); // console. log (synvisitlist synobj [0]. syndatetime = + synobj [0]. syndatetime); // var db = openDatabase ('mydb14', '1. 0', 'test db', 6*1024*1024); DB. transaction (function (tx) using tx.exe cuteSql ('create Table If Not Exists VisitInstitution (id, AKB020, AKB021, AKA020, AKA101 )'); tx.exe cuteSql ('delete FROM syncachecode WHERE inserting cuteSql ('insert INTO syncachecode (syntablename, syndatetime) VALUES (VisitInstitution, '+ synobj [0]. syndatetime + '); for (var I = 0; I
 
  

 

Console:

Obj [0] ==={ AKA101: 11, AKB020: 02162001, AKB021: lingjing community health service station, West chang'an Street, Xicheng district, ID: 11010602162001, AKA020: required} the key of objjson is ==== AKA101objjson's key is ==== AKB020objjson's key is ==== AKB021objjson's key is ==== IDobjjson's key = = AKA020

Dynamic table creation in web db

 

Web SQL dynamically creates database tables and synchronizes them with backend databases.

When a table is created for the first time, mydatetime = "1970", and the date and time returned by the background in the future are used as the synchronization time.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.