Powerful VC + beautiful extjs + Flexible Dynamic Language of (MySQL + SQLite) database + Javascript

Source: Internet
Author: User

You don't have to say much about the interface. Raise your hand!

Here, I will post the method of database access and extjs table creation.

1 access SQLite 3:

 

Function get_sqlite3_data ()
{
D = new array ();

Q = "select * From test_table ;";
DB. Query (Q );
While (db. Fetch ())
{
Idx = dB. get_array_data ("idx ");
Name = dB. get_array_data ("name ");
Email = dB. get_array_data ("email ");

A = new array (idx, name, email );
D. Push ();
}

Return D;
}

2. Access MySQL

 

2.1 JavaScript part

 

Function get_myssql_data (host, user, PWD)
{
Create_mysql_data (host, user, PWD );
// PHP = DVM. getdomaindobject ("php"); alert (PHP. get_output_string ());

D = new array ();

Q = "select * From mymatters ;";
Mysql_db.query (Q );
While (mysql_db.fetch ())
{
Name = mysql_db.get_array_data ("name ");
Amount = mysql_db.get_array_data ("amount ");
Describe = mysql_db.get_array_data ("Description ");

A = new array (name, amount, describe );
D. Push ();
}

Return D;
}

2.2 PHP part

 

 

Class mysqlaccess
{
Public $ dB;
Public $ query_result;
Public $ row_array;

Public Function open ($ host, $ user, $ PWD ){
$ This-> DB = mysql_connect ($ host, $ user, $ PWD );
// Die ($ this-> dB );
Mysql_select_db ("test ");
// $ This-> query ("create table mymatters (name varchar (30), amount int, kind varchar (16), buyself int, description varchar (255 ))");
// Die (mysql_errno ($ this-> dB). ":". mysql_error ($ this-> dB ));
}

Public Function close (){
Mysql_close ($ this-> dB );
}

Public Function query ($ SQL ){
$ This-> query_result = mysql_query ($ SQL );
// Echo ($ this-> query_result );
}

Public Function fetch (){
$ This-> row_array = mysql_fetch_assoc ($ this-> query_result );
If ($ this-> row_array)
Return true;
Return false;
}

Public Function get_array_data ($ field_name ){
Return $ this-> row_array [$ field_name];
}
}

 

3. Use extjs to generate table display data

 

Function show_mysql_data (mysql_data_panel, my_data, host, user, PWD)
{
VaR XG = ext. grid;

// Shared Reader
VaR reader = new Ext. Data. arrayreader ({},[
{Name: 'idx '},
{Name: 'name '},
{Name: 'email '}
]);

//////////////////////////////////////// //////////////////////////////////////// ////////
// Grid 1
//////////////////////////////////////// //////////////////////////////////////// ////////

VaR grid1 = new XG. gridpanel ({
Store: New Ext. Data. Store ({
Reader: reader,
Data: my_data
}),
CM: New XG. columnmodel ([
{ID: 'idx', header: "name", width: 3, sortable: True, dataindex: 'idx '},
{Header: "quantity", width: 10, sortable: True, dataindex: 'name '},
{Header: "Description", width: 10, sortable: True, dataindex: 'email '}
]),
Viewconfig :{
Forcefit: True
},
Width: 600,
Height: 300,
Collapsible: True,
Animcollapse: false,
Title: 'mysql data: '+ host + ":" + User + "-" + PWD,
Iconcls: 'icon-grid ',
Renderto: mysql_data_panel
});
}

 

Download

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.