Implementation of SQL statements in Javascript

Source: Internet
Author: User

For example, sort JavaScript arrays.
Delete, select, and group array data.

So, later I was excited.
It's not enough.

Write an SQL library that can be applied in Javascript
Later I thought, why can't I use JavaScript to directly connect to the database?
Another class library for JavaScript direct connection to SQL data

Later, I thought that I could use SQL statements to operate the HTML Dom model.

Later, I saw the implementation of Web DB in HTML5.
Therefore, webdb is the SQLite encapsulation in chrome and safari.

So there is:

1. obtain data from the server and execute SQL operations:

CopyCode The Code is as follows: _ sqlproxyurl _ = 'sqlproxy. php ';
_ Sqlserverhost _ = 'localhost ';
_ Sqlusername _ = 'root ';
_ Sqlpassword _ = '';
_ Sqldatabase _ = 'managing management ';

VaR result = "select * from room" .onserver(cmd.exe cutesql ();
For (VAR I = 0; I <result. length; I ++ ){
// Do something here... using result [I];
}

2. Operate JavaScript Object array and execute SQL operations:

Copy code The Code is as follows:

VaR room = [
{
ID: 'bot ',
Name: 'test ',
Sex: True
},{
ID: 2,
Name: 'test8 ',
Sex: True
},{
ID: 3,
Name: 'test5 ',
Sex: false
},{
ID: 4,
Name: 'test2 ',
Sex: True
}];

SQL = "select max (ID) as bid, sum (ID) as total from records where name like \" test % \ "group by sex order by ID DESC, name ASC ";
VaR result = SQL .exe cutesql ();
For (VAR I = 0; I <result. length; I ++ ){
// Do something here... using result [I];
};
"Create table mytable". executesql ();
For (var j = 0; j <100; j ++ ){
"Insert into mytable (ID, name, sex) values (2, 'hangsan', true)". executesql ();
};

SQL statements are all written out. Secure?

For security issues, first of all, this is not intended for Internet applications, but for LAN. Second, the database connection has SSL encryption. In fact, HTTP also has SSL. The remote call service is only one of the four modules of jsql. You can also operate the client objects array, SQLite in the browser, and Dom in the webpage without passing through services. My SQL here only represents a language specification, which is suitable for but not limited to the back-end SQL database. There are three modules for front-end operations.

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.