Recently in the Project Hybrid app development, the project has a large number of JS code running on Android devices. The use of a lot of HTML5 new features, have not encountered before, do not understand, here to record the knowledge of adding point front. In hybrid app development, it's often necessary to use caching features, such as when you enter data on a page form control, and you want to see it again the next time you exit the app, such as having the ability to save drafts in your projec
Tutorial 05-dishi and websql, hbuilderwebsqlDishi Introduction
Dishi is a planning app developed with HBuilder,
HBuilder, mui, nativejs, and h5 features are used.Expectation
Currently, it is only developed at the todolist level,
In the future, plans will be made into planning apps such as daily, monthly, and annual plans.URL
Official Website: http://uikoo9.com/dishi
Source: http://git.oschina.net/uikoo9/uikoo9-dishi
Tutorial
In the future, we will use
, showing completed to-do items, specific features:1. Right-swipe to-do list pops up2. Click on the top right corner to ejectAll pagesAll pages have exit and Menu buttonsImplementation of data storageHbuilder developed apps, data storage is available in the following ways:1. Online databaseAs with traditional apps, you can store your data on a online database,Hbuilder app that can manipulate databases through the MUI encapsulated AJAX approach.2.web StorageUsing the new features of H5, Localstor
Label:The common operation of the Websql is a package, the project is based on PhoneGap, but the PHONEGAP default has integrated the database operation plug-in, so no need to configure what, directly use can be:/*** Database Operation helper class, define object, data operation method are defined here */var dbname= ' mydb '; var version= ' 1.1 '; var dbdesc= ' mydb '; var table_picture= ' Be_ Picture '; var dbsize=30000;var db=null;/** * Open Database
There are several ways to websql storage:OpenDatabase: This method uses an existing database or creates a new database to create a database object.Transaction: This method allows us to perform transaction processing;ExecuteSQL: This method is used to execute SQL statements;1 var db = OpenDatabase (name,version,displayname,estimatesize,creationcallback);Name: Names of databases;Version: The revision number of the database;DisplayName: Description of th
used the Websql, and then using Websql, when we met a few pits1. Database operation is asynchronous, sometimes very annoying, for example, I want to get 100 questions, the operation of these topics, return to the method, I did not use the callback function I used is the method of the parameter, feel used generally, sometimes, too complex operation, often problems, because after all, is the function, closur
This article mainly introduces HTML5 Storage functions and webSQL related operations, including the use of Storage attributes and the use of JavaScript For webSQL operations, for more information, see html5. two mechanisms are introduced, similar to HTTP session cookies, to store structured data on the client and overcome the following Disadvantages.
Each HTTP request contains Cookies, causing the transmis
Example of using Web SQL in HTML 5: websql
Web SQL simulates databases in a browser and can use JS to operate SQL to read and write data. However, this feature currently does not support many browsers, and its W3C specification has been discontinued, it seems that its prospects are not very clear.
W3C specification: http://www.w3.org/TR/webdatabase/#dom-sqltransaction-sync-executesql)
Supported browsers and versions:
Safari (3.2 +)Chrome (3.0 +)Opera
incoming object properties and the value of the property.
User.all (). One (function (user) {Console.log (user);}); Query out the first User objectUser.load ("6c22fd66801c41728ae5a6bce0a8ee54", function (user) {Console.log (User.Name);}); Query out User object with ID "6c22fd66801c41728ae5a6bce0a8ee54"User.findby ("name", "Mark", function (user) {Console.log (User.age);}); Query out name is Mark's User objectThe querycollection,persistence.js that are returned by the query provide rich exten
SELECT * from Table ORDER by ID DESC Limit 10,9Limit semantics: Skip 10 lines and take 9 rowsReference:SQLite limit Usage If I'm going to 11-20 of the Account table data Select * From account Limit 9 Offset 10; The above statement means getting data from the account table, skipping 10 rows, taking 9 rows well, I think this feature is enough for many web medium-sized websites to use this. You can also write a select * from the account limit10,9 with the same effect as above. General public beta:
("Query data Failed!" "+message);
});
}); }
/** * (2) The Db.transaction method can set a callback function that can accept an argument that is the object of the transaction that we opened.
This object can then be used to execute SQL scripts, which can be combined with the following steps.
* (3) Execute the query through the ExecuteSQL method. * TS.EXECUTESQL (Sqlquery,[value1,value2..],datahandler,errorhandler) * Parameter Descr
Label:1. Create or open a database (OpenDatabase)var db = OpenDatabase (' dbname ', ' 1.0 ', ' discription ', 2 * 1024); Currently testing is only supported by Chrome browser Opendatabasek Five parameters are: database name, version number, description, database size, create callback function. The callback function is an optional parameter.2. Execute SQL statementsDb.transaction (function(TX) {Tx.executesql (' CREATE TABLE IF not EXISTS T1 (id unique, log) ', [],function(TX, result) {},function(
Label:Recently in writing Websql, every time in the browser console to execute SQL too laborious, and the brain is not good, always forget what the last initialized database, so wrote a very simple websql visualization tool, said the tool is a bit large, is to facilitate, today shared out, the need of classmates, Please take away, did not do too much logic judgment, have the question can reply me, I again t
Label:In addition to Sessionstorage and Localstorage, HTML5 also supports local data storage via a local database, and HTML5 uses the "SQLite" file-based database, which is more concentrated on embedded devices and is familiar with ios/ Android development students, should be familiar with SQLite database. Websql allows us to create a local database directly on the browser side of the JS API, and supports standard SQL CRUD operations, making it easie
query portal for a table is actually starting with the object defined by the Persistence.define. For example, the User defined in the above article. User.all () will return directly to a querycollection that will contain all the User objects. User.load () can load a user object based on the username passed in by the users. User.findby () can query a collection of user objects that meet the criteria and return them based on the users ' passed-in object properties and the values of the properties
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.